问题
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:
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.
回答2:
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
回答3:
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
来源:https://stackoverflow.com/questions/2198257/confusion-in-understanding-classpath