25 Sept 2011

Finding Class Files


The java run time environment look for the Bootstrap, Extension and User-defnied or third-party classes, in that specific order.
Lets look what and where are they  

Java run time environment look for the classes that are required for Java Platform  in  
<java-home>jre/lib/  directory and  these classes are called Bootstrap classes.
More specifically JVM looks for rt.jar and i18n.jar files.
 Location of these files are stored in sun.boot.class.path System property.
SDK Tools such as javac and java are located at <jdk-ome>/lib/tools.jar file



Classes, which extends the Java Platform , can be found in <java-home>jre/lib/ext/ directory. These classes are called  Extension classes. For example jar file required for the specific database for using the JDBC must be stored here.  

The directory in which these classes are located is platform specific.


User-defined or Third party class or jar files required by the application must be located in the classpath variable. A classpath variable points to the directory of required files .By default current directory is set as a classpath variable. One can set the classpath using command line option –cp or by setting the CLASSPATH environment variable. Both these methods override the default value of classpath variable.
It must be noted that user is not required to set the classpath for Bootstrap and Extension classes

Multiple paths can be specified in classpath entry by  using the system dependent path separator . In that case ,specified order is important because in JVM will look for class files in that specific order.