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

Writing My First Java Program

This section provides a tutorial example on how to write, compile, and execute the first Java program with JDK 1.5.0. Notes were taken in 2005.

Use NotePad to enter the first Java program into a file called Hello.java:

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

Then compile this program in a command window with the javac command:

>c:\Program Files\Java\jdk1.5.0_09\bin\javac Hello.java

To execute the program, use the java command:

>c:\Program Files\Java\jdk1.5.0_09\bin\java -cp . Hello
Hello world!

Congratulations, you have successfully entered, compiled and executed your first Java program.

Table of Contents

 About This Book

 Installing JDK 1.4 on Windows 2000

Installing JDK 1.5 on Windows XP

 Downling and Installing JDK 1.5

Writing My First Java Program

 Installing JDK 1.6 on Windows XP

 Execution Process, Entry Point, Input and Output

 Bits, Bytes, Bitwise and Shift Operations

 Managing Bit Strings in Byte Arrays

 StringBuffer - The String Buffer Class

 System Properties and Runtime Object Methods

 Execution Threads and Multi-Threading Java Programs

 ThreadGroup Class and "system" ThreadGroup Tree

 Synchronization Technique and Synchronized Code Blocks

 Deadlock Condition Example Programs

 Garbage Collection and the gc() Method

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2008
Writing My First Java Program