The CLASSPATH environment variable is one way to tell applications, where to look for user classes or in other way we can say that Java determines where to look for the classes referenced by a program. These applications can include your JDK or your one simple program. Lets say in your program you have an import statement like com.firstpackage.demo , in this case the compiler and JVM must know where to find com/firstpackage/demo class.
But in the CLASSPATH we need not to specify location of normal J2SE packages such as java.util or java.io or java.lang etc. also the classes and packages present in the ext directory (e.g. j2sdk\jre\lib\ext ) need not to be referenced using CLASSPATH, Java automatically look in those directories.
Specifying location in CLASSPATH :
CLASSPATH environment variable can specify the location of classes in directories , in JAR files and in ZIP files.
1. For jar files , we need to specify entire path and jar file name.
2. For classes in a directory then we need to specify the path up to excluding the name of the package the classes are in.
3. And classpath for both entries we can write separating by ;
- Blogger Comment
- Facebook Comment