Now will start our first java program, lets look at the following program,

public class TestClass{

public static void main(String [ ] args) {

System.out.println(” Hello, How are you? “);


open notepad write the code and Save your file as in C:\mywork,  To make sure your file name is, (not, first choose “Save as file type:” All files, then type in the file name
Before going to execute it, first let me explain the requirements,
Implementation of the Java Platform, Standard Edition Development Kit (JDK 6). Download and install the latest version of the Java Platform, Standard Edition Development Kit (JDK 6 Update 21). Note the installation directory for later – probably something like C:\Program Files\Java\jdk1.6.0_21\bin.
now open command prompt.
C:\> cd \mywork

This makes C:\mywork the current directory.


dirThis displays the directory contents.  You should see among the files.

C:\mywork> set path=%path%;C:\>cd “Program Files\Java\jdk1.6.0_20\bin”

This tells the system where to find JDK programs.

C:\mywork> javac

This runs javac.exe, the compiler.  You should see nothing but the next system prompt…

C:\mywork> dir

javac has created the TestClass.class file.  You should see and TestClass.class among the files

.C:\mywork> java TestClass

This runs the Java interpreter.  You should see the program output:

Hello, How are you?

If the system cannot find javac, check the set path command.  If javac runs but you get errors, check your Java text.  If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java TestClass command.  Java is case-sensitive!

It is possible to make path setting permanent , but becarefull while doing that,

In Windows XP, go to Control Panel, choose “System,” click on the “Advanced” tab, click on the “Environment variables” button. In the lower list, “System variables,” click on Path:




Click “Edit” and at the end append

;C:\Program Files\Java\jdk1.6.0_20\bin

(or the path to the appropriate folder where the latest version of JDK is installed).  Do not put spaces before the appended path string.

Click OK on the path edit box and OK on the Ennvironment Variables box.  The new setting will go into effect next time you run Command Prompt.

Thats it, now u can start coding and executing.