Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.00

Launching Hello.java - My First Java Program

This section provides a tutorial example on how to launch a simple java program using the 'java' tool without any options.

To test the Java launcher, 'java', I wrote the following Java file, Hello.java:

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

Here is what I did in a command window to compile Hello.java into Hello.class:

C:\herong>javac Hello.java

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

C:\herong>java Hello
Hello world!

As you can see, launching a simple Java application is easy - Run the 'java' command without any options.

Sections in This Chapter

'java' - Java Launching Command and Options

Launching Hello.java - My First Java Program

Option "-classpath" - Specifying Class Path

Option '-jar' - Specifying Executable JAR Files

Option '-X' - Specifying Non-Standard Options

'javaw' - Launching Java Programs without Console

Dr. Herong Yang, updated in 2008
Launching Hello.java - My First Java Program