tags:

views:

60

answers:

3

I'm confused in understanding, how java interpretor and java compiler searches for all the necessary jar files it requires from environment variables. As I have only set the set path variable for JDK directory, but I've not set any variable to search for any class libraries, which jvm requires. How can it search those important jar files?

+1  A: 

CLASSPATH is an enviromental variable is like the path file (which helps windows to find executables). It lists a set of all places the JVM looks for classes. You can also give the classpath on the command line when starting the jvm and java compiler

Thirler
+3  A: 

Which jar files are you talking about? Java already knows about the jar files it "owns" (such as rt.jar) - you don't have to tell it about them explicitly. This is known as the bootclasspath - you can override it, but usually you don't want to.

Jon Skeet
+2  A: 

For better understanding of how classes are found and loaded by JVM read this.

http://java.sun.com/j2se/1.3/docs/tooldocs/findingclasses.html

Chandru
+1, but more recently: http://java.sun.com/javase/6/docs/technotes/tools/findingclasses.html
trashgod
@trashgod Thanks for pointing that out.Didn't notice that it was for 1.3. :( But most of the concepts still hold true thanks to Java's backward compatibility.
Chandru