Running a Java Program from Command Prompt

04 May,2012 by Tom Collins

Question: I’m receiving this message when attempting to compile some java code:

'javac' is not recognized as an internal or external command, operable program or batch file

How can I fix this problem?

Answer: If  you installed the JDK in C:\jdk1.6.0. At the prompt you would type the following command and press Enter:


If you choose this option, you'll have to precede your javac and java commands with C:\jdk1.6.0\bin\ each time you compile or run a program.

If the system cannot find javac or java, check the set path command. 

It is possible to make the path setting permanent but  be  careful because your system might crash if you make a mistake.

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:

Set java path


Click "Edit" and at the end of the string, append

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

(or the path to the relevant directory where the latest version of JDK is installed). Watch for spaces.

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


Author: Rambler(


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on Running a Java Program from Command Prompt

Comments are moderated, and will not appear until the author has approved them. | DB2 Performance Tuning | DBA DB2:Everything | FAQ | Contact | Copyright