Compiling - 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 in a working directory C:\herong

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

C:\>cd \herong


C:\herong>dir Hello.*
   416 Hello.class

As you can see from this tutorial, the simplest way to use the 'javac' Java compiler is to:

Last update: 2015.

Table of Contents

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

'javac' - The Java Program Compiler

 'javac' - Java Compilation Command and Options

Compiling - My First Java Program

 Option '-classpath' - Specifying Class Path

 Option '-sourcepath' - Specifying Source Path

 Option '-d' - Specifying Output Directory

 Two Types of 'import' Statements

 'import' Statements Processed by 'javac'

 Option "-g" - Controlling Debugging Information

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

 'jar' - The JAR File Tool

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials


 PDF Printing Version