• Post Reply Bookmark Topic Watch Topic
  • New Topic

how classpath works??  RSS feed

 
aashini shah
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand how CLASSPATH works? and how JVM finds the path.

I have set environment variable CLASSPATH to c:\jdk1.4\bin . i also tried c:\jdk1.4\bin\
but still i need to use set path=c:\jdk1.4\bin on command prompt.

CLASSPATH doesn't work.

what should i do?
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by aashini shah:
I don't understand how CLASSPATH works? and how JVM finds the path.

I have set environment variable CLASSPATH to c:\jdk1.4\bin . i also tried c:\jdk1.4\bin\
but still i need to use set path=c:\jdk1.4\bin on command prompt.

CLASSPATH doesn't work.

what should i do?



CLASSPATH and PATH environment variables serves two different purposes. The CLASSPATH is used to find the class files. There should be no class files in the jdk bin directory. The jdk bin directory should contain the executables, which you find with the PATH variable.

Henry
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by aashini shah:
...what should i do?

First, you should update your system PATH variable to include c:\jdk1.4\bin so that you don't need to type this all the time. This is covered in step 4 of the JDK installation instructions (assuming Windows).

Second, you should probably remove the system CLASSPATH variable. As Henry pointed out, setting this to the JDK's bin directory does nothing, because you shouldn't have class files there. In fact, this preempts Java's default behavior of looking for classes in the current directory, so it's likely to cause you problems. For background on CLASSPATH, see Setting the class path.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!