This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java in General and the fly likes PATH and CLASSPATH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "PATH and CLASSPATH" Watch "PATH and CLASSPATH" New topic


Monoj Roy
Ranch Hand

Joined: Oct 10, 2007
Posts: 98
I am working with WSAD 5.1.2 and never have used notepad or any text editor to write Java Program .

When I am writing a program in notepad and want to run it I am getting problem of PATH and CLASSPATH are not set correctly .

Can any body please help making understand me what PATH and CLASSPATH points to?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 36599
A classic beginner's problem, which causes more people more trouble than almost anything else when they start.

CLASSPATH is usually set up for simple applications already. It usually contains an entry with a single . representing whichever directory the user happens to open in the shell or terminal or command prompt window. If you are using additional .jar files you may need to add their location to the CLASSPATH.
CLASSPATH is where the computer looks to find the classes you are using.

PATH is usually not set up and has to be set up by the user. There are descriptions of the problems seen here in the Java tutorial; find the link to setting the PATH variable.
PATH tells the computer where to look for the "java" "javac" "javadoc" etc executable files.
Follow the instructions for setting the PATH to the letter. Make sure you get rid of any old Java PATHs. Ask the Bartenders to transfer this thread to beginners' where it belongs. Tell us whether you have got your application to work, and good luck with it. CR
Monoj Roy
Ranch Hand

Joined: Oct 10, 2007
Posts: 98
Thank you for the response .It worked but I have a confusion .

I have set my

C:\Program Files\SSH Communications Security\SSH Secure Shell;

and the CLASSPATH:
C:\Program Files\IBM\SQLLIB\java\jdk\bin;
C:\Program Files\IBM\My Help\plugins\org.apache.ant_1.6.5\bin

and it is working when I am writing a simple .java file in any location
Now my question is ...

As I understand PATH refer to the java and javac command PATH ,so they must be included in PATH user variable to avoid the repetation of fully qualified path name of those command but in my case I have not included the in the path variable but have included in CLASSPATH then why I am not getting error?Why I can run java ,javac command from any directory location?
Please help me to understand the concept ..
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13884

Why do you have ant.jar in your PATH? It doesn't belong there.

The PATH environment variable is a setting for the operating system. It tells the operating system where to look for executable files, such as java.exe or javac.exe. You must put the bin directory of your JDK installation in the PATH, so that the operating system knows where to look for java.exe and javac.exe. If you can run javac without getting an error, then either the bin directory of the JDK is already in the PATH, or your current directory is the JDK bin directory.

The CLASSPATH environment variable is a setting for Java. It tells Java where to look for class files. The operating system doesn't look at CLASSPATH. It's Java-only.

Try typing the following command in a command prompt window to see what your PATH is set to:

echo %PATH%

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Monoj Roy
Ranch Hand

Joined: Oct 10, 2007
Posts: 98
Thanks a lot . Now its clear ..very clear
I just used echo %PATH% and there is many more included in PATH and one of them is jdk/bin as well .
Yes I can now match everything ..Thanks again to clear the point .
Consider Paul's rocket mass heater.
subject: PATH and CLASSPATH
Similar Threads
Setting Java Classpath in Microsoft XP OS
'java' is not recognized as an internal or external command
classpath in java
Applet notinited
problems installing java