First Java Program

The following is a simple Java program to display a message on the screen.
// a very simple java program 
public class First
{
    // entry point of the program
    public static void main(String args[])
    {
       // display a simple message 
       System.out.println("Journey Begin Here!");
    }
}

Compiling and Running

Save the above program under filename First.java

Compile the programs using JAVAC.EXE. Make sure you have access to JAVAC by including JDK1.5.0\BIN directory in system PATH as shown below.

 C:\jdk1.5.0\Programs>PATH  c:\jdk1.5.0\bin;%PATH% 

Above command ensures that BIN directory, which contains JAVAC.EXE and JAVA.EXE, is in system path.

Compile .java file as follows

 c:\jdk1.5.0\programs>javac  First.java 

Run the program by using JAVA as follows.

 c:\jdk1.5.0\programs>java First