Compiling Hello.java - My First Java Program

This section provides a tutorial example on how to compile a Java program using the 'javac' tool without any options.

To test the compiler, I wrote my first Java program with a text editor:

class Hello {
   public static void main(String[] a) {
      System.out.println("Hello world!");
   }
}

Then I saved this program with the file Hello.java in the current directory.

Here is what I did in a command window to compile Hello.java with the 'javac' Java compiler tool. The output of the compilation is a Java class file called Hello.class:

herong> javac Hello.java

herong> dir Hello.*
   416 Hello.class
   116 Hello.java

So the simplest way to use the 'javac' Java compiler is to:

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

 java - The Java Program Launcher

 jar - The JAR File Tool

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 jpackage - Binary Package Builder

 javadoc - The Java Document Generator

 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

 jrunscript - Script Code Shell

 Miscellaneous Tools

 native2ascii - Native-to-ASCII Encoding Converter

 JAB (Java Access Bridge) for Windows

 Archived Tutorials

 References

 Full Version in PDF/EPUB