Java Tools Tutorials - Herong's Tutorial Notes - Version 5.31, by Dr. Herong Yang
Option "-g" - Controlling Debugging Information
This section provides a tutorial example on how to use the '-g' option to generate debugging information into the class output files. Debugging information in class file can be used by any debugging tools.
As we see earlier, the "-g" compiler option can be used to control how much debugging information should be generated into the class files. Here are the choices on how to use this option:
Choice Option Information generated in class 1 -g:none No debug information 2 -g:lines Line number only 3 -g:lines,source Line number & source file 4 (default) Same as #3 5 -g:lines,source,vars Line number, source file & variables 6 -g Same as #5
Of course, the more debugging information you generate in a class file, the more debugging power you will get when you debug this class. However, once your source code is fully debugged, you should recompile your code with "-g:none", so that you don't distribute you class file will any debugging information.
Leaving debugging information in your class file will have the following negative effects:
Last update: 2015.
Table of Contents