Java compiling - Use javac -g:none to reduce Java class file size

I was scanning over a Java performance programming book the other night, and it reminded me about a javac compiler option I had forgotten about. The short story is that they suggest you can use this command:

javac -g:none  

to compile your Java class files when you're ready to deploy your application. This command does not put any debugging information in your .class files, and seems to reduce the size of these files by 10-16%. (I've tried a few tests and a 16% reduction often occurs.) In deployment you won't need this information in your class files, so why put it in, right?

With Java applets a 16% reduction in class size will yield a 16% reduction in download time, so the payback there is immediate. Of course in Java web applications you can very easily automate this in your build process with ant, so it's something I'll be doing right away, and strongly recommend.

 

Post new comment

The content of this field is kept private and will not be shown publicly.