• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PATH and CLASSPATH

 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 49361
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the response .It worked but I have a confusion .

I have set my

PATH:
C:\Program Files\SSH Communications Security\SSH Secure Shell;
c:\ant.jar;
%PATH%;
%ANT_HOME%\bin

and the CLASSPATH:
.;
C:\PROGRA~1\IBM\SQLLIB\java\db2java.zip;
C:\PROGRA~1\IBM\SQLLIB\java\db2jcc.jar;
C:\PROGRA~1\IBM\SQLLIB\java\sqlj.zip;
C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cisuz.jar;
C:\PROGRA~1\IBM\SQLLIB\java\db2jcc_license_cu.jar;
C:\PROGRA~1\IBM\SQLLIB\bin;C:\PROGRA~1\IBM\SQLLIB\java\common.jar;
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
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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%
 
Monoj Roy
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 .
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic