Software >> Development >> Languages >> Java >>  How to write and execute first java program

Windows platform ================ eg. using JDK 1.5.0_07 1. install jdk 2. add the jdk bin directory into PATH eg. set PATH=%PATH%;C:\Program Files\Java\jdk1.5.0_07\bin 3. write HelloWorld.java public class HelloWorld { public static void main ( String [] args ) { System.out.println( "Hello World" ); } // end main } // end class HelloWorld 4. Change dir to where your .java source is located, compile javac.exe -classpath . HelloWorld.java 5. execute java.exe -classpath . HelloWorld