How to set PATH and Class Path to run JAVA program

Set PATH and Class Path to run JAVA program

If you have installed JRE and unable to run the java program, then stop for a moment, you will not be able to run the program till you do not set the path and classpath of your installed JRE.

If you want to set path and classpath using command prompt

1. PATH

SYNTAX

C:\>set path=%path;C:\Java\jdk1.6.0_03\bin%

Here you have to give the JDK/bin directory path

2. Classpath

SYNTAX

C:\>set classpath=%classpath;C:\Java\jdk1.6.0_03\lib%

Here you have to give the JDK/lib path

If you are using windows to set the path and classpath, just follow the steps

Right Click on the MyComputer > Properties > Advanced > Environment Variables

set path and classpath in java
set path and classpath in java

Now you will have a window showing user variables and System variables.

You have to find the variable name path, if it already contains path variable, just edit the path folder and edit the value, include ;C:\Java\jdk1.5.0_03\bin; after the last value.

Set Path in Java to Run Program
Set Path in Java to Run Program

If you are unable to find the PATH folder, just create new and give variable name path and value C:\Java\jdk1.5.0_03\bin

Set Classpath to Run Java Program
Set Classpath to Run Java Program

Same case in CLASSPATH, if already contains, just edit it with ;C:\Java\jdk1.5.0_03\lib; or create it and give name CLASSPATH and value C:\Java\jdk1.5.0_03\lib

Now you can compile and run the java program easily.

I will show you the steps in my video tutorials.

SET JAVA PATH and CLASSPATH in Window 7

How to Install Java

Setting up your computer to run Java