Thursday, December 18, 2008

How to set Java Path to run Java Program

Please read my earlier post about How to install Java before setting the Java Path to compile java file.

Once you are done with Java Installation,Right click on the My Computer Icon of your desktop or if you dont have My Computer icon on your desktop then right click on the My Computer in File Explorer.

-> Select the Properties Item

-> Select the Advanced Tab

-> Click Envirnment Variables Button

-> Find path under System Variable section, select it and click edit button

-> It will open a pop up window , append %Java Installation Dir%\bin (make sure that before adding this value, you are placing a semicolon (;) and then appending the value. Semi colon is used as a separator between two different location in the Path Variable.) at the end in the Value field.

Note : %Java Installation Dir% means the folder where you have installed the java,but the path you have given upto bin folder under installed folder as it contains javac.exe (java compiler) and java.exe (executs Java )

Save your changes.

How to verify:

1.Open a command prompt

2. type java -version and press enter

if you are able to see some text on command prompt as

java version "1.5.0_14"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03)

Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing)

Means Java is installed properly and your pc environment path is set to compile and run a java program.

If you are unable to get the above mentioned text, please verify whether you set the Environment variable properly as well as check the location you provided.

I hope it will help you to understand how to set path in computer to run java program.

No comments:

Post a Comment