"javac -verbose" - Printing Compilation Details

This section provides a tutorial example on how to use the '-verbose' option to print compilation details.



If you want to see what the compiler is doing during the compilation process, you can use the "javac" option "-verbose".

Here is my test of "javac -verbose" command using JDK 12:

C:\herong>\Progra~1\java\jdk-12.0.1\bin\javac -verbose Hello.java

[parsing started SimpleFileObject[C:\herong\Hello.java]]
[parsing completed 16ms]

[loading /modules/jdk.jdeps/module-info.class]
[loading /modules/java.management/module-info.class]
[loading /modules/java.transaction.xa/module-info.class]
[loading /modules/jdk.security.auth/module-info.class]
[loading /modules/jdk.internal.le/module-info.class]
[loading /modules/jdk.charsets/module-info.class]
[loading /modules/jdk.editpad/module-info.class]
[loading /modules/java.xml.crypto/module-info.class]
[loading /modules/jdk.internal.vm.ci/module-info.class]
[loading /modules/jdk.internal.vm.compiler.management/module-info.class]
...

[search path for source files: .]
[search path for class files: C:\Progra~1\java\jdk-12.0.1\lib\modules,.]
[loading /modules/java.base/java/lang/Object.class]
[loading /modules/java.base/java/lang/String.class]
[loading /modules/java.base/java/lang/Deprecated.class]
[loading /modules/java.base/java/lang/annotation/Retention.class]
[loading /modules/java.base/java/lang/annotation/RetentionPolicy.class]
[loading /modules/java.base/java/lang/annotation/Target.class]
[loading /modules/java.base/java/lang/annotation/ElementType.class]
[checking Hello]
[loading /modules/java.base/java/io/Serializable.class]
[loading /modules/java.base/java/lang/AutoCloseable.class]
[loading /modules/java.base/java/lang/System.class]
[loading /modules/java.base/java/io/PrintStream.class]
[loading /modules/java.base/java/lang/Appendable.class]
[loading /modules/java.base/java/io/Closeable.class]
[loading /modules/java.base/java/io/FilterOutputStream.class]
[loading /modules/java.base/java/io/OutputStream.class]
[loading /modules/java.base/java/io/Flushable.class]
[loading /modules/java.base/java/lang/Comparable.class]
[loading /modules/java.base/java/lang/CharSequence.class]
[loading /modules/java.base/java/lang/constant/Constable.class]
[loading /modules/java.base/java/lang/constant/ConstantDesc.class]
[wrote Hello.class]
[total 250ms]

The compiler seems to load classes needed to run the compiler first. Then it loads classes that are required for the Hello.java program.

By the way, Oracle are changing the compilation process between JDK versions. Here is my test of "javac -verbose" command using JDK 10:

C:\herong>\Progra~1\java\jdk-10.0.1\bin\javac -verbose Hello.java

parsing started SimpleFileObject[C:\herong\Hello.java]]
parsing completed 31ms]

loading /modules/jdk.management.jfr/module-info.class]
loading /modules/javafx.deploy/module-info.class]
loading /modules/java.xml/module-info.class]
loading /modules/java.desktop/module-info.class]
loading /modules/java.security.sasl/module-info.class]
loading /modules/jdk.management.agent/module-info.class]
loading /modules/jdk.unsupported/module-info.class]
loading /modules/javafx.fxml/module-info.class]
loading /modules/jdk.rmic/module-info.class]
loading /modules/javafx.swing/module-info.class]
... 

search path for source files: .]
search path for class files: C:\Progra~1\java\jdk-10.0.1\lib\modules,.]
loading /modules/java.base/java/lang/Object.class]
loading /modules/java.base/java/lang/String.class]
loading /modules/java.base/java/lang/Deprecated.class]
loading /modules/java.base/java/lang/annotation/Retention.class]
loading /modules/java.base/java/lang/annotation/RetentionPolicy.class]
loading /modules/java.base/java/lang/annotation/Target.class]
loading /modules/java.base/java/lang/annotation/ElementType.class]

checking Hello]
loading /modules/java.base/java/io/Serializable.class]
loading /modules/java.base/java/lang/AutoCloseable.class]
loading /modules/java.base/java/lang/System.class]
loading /modules/java.base/java/io/PrintStream.class]
loading /modules/java.base/java/lang/Appendable.class]
loading /modules/java.base/java/io/Closeable.class]
loading /modules/java.base/java/io/FilterOutputStream.class]
loading /modules/java.base/java/io/OutputStream.class]
loading /modules/java.base/java/io/Flushable.class]
loading /modules/java.base/java/lang/Comparable.class]
loading /modules/java.base/java/lang/CharSequence.class]

wrote SimpleFileObject[C:\herong\Hello.class]]
total 343ms]

Here is my test of "javac -verbose" command using JDK 1.8:

C:\herong>\Progra~1\java\jdk1.8.0\bin\javac -verbose Hello.java

[parsing started RegularFileObject[Hello.java]]
[parsing completed 47ms]

[search path for source files: .]
[search path for class files: 
   C:\progra~1\java\jdk1.8.0\jre\lib\resources.jar,
   C:\progra~1\java\jdk1.8.0\jre\lib\rt.jar,
   C:\local\jdk\jre\lib\sunrsasign.jar,
   ...

[loading ZipFileIndexFileObject[
   C:\progra~1\java\jdk1.8.0\lib\ct.sym
   (META-INF/sym/rt.jar/java/lang/Object.class)]]
[loading ZipFileIndexFileObject[
   C:\progra~1\java\jdk1.8.0\lib\ct.sym
   (META-INF/sym/rt.jar/java/lang/String.class)]]

[checking Hello]

[loading ZipFileIndexFileObject[...java/lang/Serializable.class)]]
[loading ZipFileIndexFileObject[...java/lang/AutoCloseable.class)]]
[loading ZipFileIndexFileObject[...java/lang/Byte.class)]]
...
   
[wrote RegularFileObject[Hello.class]]
[total 1924ms]



 

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

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

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 java - The Java Program Launcher

 jdeps - The Java Class Dependency Analyzer

 jdeprscan - The Java Deprecated API Scanner

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jhsdb - The Java HotSpot Debugger

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

 jshell - Java Language Shell

 native2ascii - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 Full Version in PDF/EPUB