Java Tools Tutorials - Herong's Tutorial Examples - v6.23, by Herong Yang
"javac -g" - Controlling Debugging Information
This section describes 'javac -g' options 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 with any debugging information.
Leaving debugging information in your class file will have the following negative effects:
Table of Contents
►javac - The Java Program Compiler
javac - Java Compilation Command and Options
Compiling Hello.java - My First Java Program
"javac -classpath" - Specifying Class Path
"javac -verbose" - Printing Compilation Details
"javac -sourcepath" - Specifying Source Path
"javac -d" - Specifying Output Directory
Two Types of "import" Statements
"import" Statements Processed by "javac"
►"javac -g" - Controlling Debugging Information
"javac --module" - Compiling Entire Module
"javac -X" - Specifying Non-Standard Options
java - The Java Program Launcher
jpackage - Binary Package Builder
javadoc - The Java Document Generator
jdeps - The Java Class Dependency Analyzer
jdeprscan - The Java Deprecated API Scanner
jcmd - The JVM Diagnostic Tool
jconsole - Java Monitoring and Management Console
jstat - JVM Statistics Monitoring Tool
jhsdb - The Java HotSpot Debugger
jvisualvm (Java VisualVM) - JVM Visual Tool
javap - The Java Class File Disassembler
keytool - Public Key Certificate Tool
jrunscript - Script Code Shell
native2ascii - Native-to-ASCII Encoding Converter