What is CLASSPATH in Java
Classpath in Java is path to directory or list of directory which is used by ClassLoaders to find and load class in Java program. Classpath can be specified using CLASSPATH environment variable which is case insensitive, -cp or -classpath command line option or Class-Path attribute in manifest.mf file inside JAR file in Java. In this Java tutorial we will learn What is Classpath in Java, how Java resolve classpath and How Classpath works in Java along side How to set classpath for Java in windows and UNIX environment. I have experience in finance and insurance domain and Java is heavily used in this domain for writing sophisticated Equity, Fixed income trading applications. Most of these investment banks has written test as part of there core Java interview questions and I always find at least one question related to CLASSPATH in Java on those interviews. Java CLASSPATH is one of the most important concepts in Java, but, I must say mostly overlooked. This should be the first thing you should learn while writing Java programs because without correct understanding of Classpath in Java you can't understand how Java locates your class files. Also don't confuse Classpath with PATH in Java, which is another environment variable used to find java binaries located in JDK installation directory, also known as JAVA_HOME. Main difference between PATH and CLASSPATH is that former is used to locate Java commands while later is used to locate Java class files.
Read more »
Classpath in Java is path to directory or list of directory which is used by ClassLoaders to find and load class in Java program. Classpath can be specified using CLASSPATH environment variable which is case insensitive, -cp or -classpath command line option or Class-Path attribute in manifest.mf file inside JAR file in Java. In this Java tutorial we will learn What is Classpath in Java, how Java resolve classpath and How Classpath works in Java along side How to set classpath for Java in windows and UNIX environment. I have experience in finance and insurance domain and Java is heavily used in this domain for writing sophisticated Equity, Fixed income trading applications. Most of these investment banks has written test as part of there core Java interview questions and I always find at least one question related to CLASSPATH in Java on those interviews. Java CLASSPATH is one of the most important concepts in Java, but, I must say mostly overlooked. This should be the first thing you should learn while writing Java programs because without correct understanding of Classpath in Java you can't understand how Java locates your class files. Also don't confuse Classpath with PATH in Java, which is another environment variable used to find java binaries located in JDK installation directory, also known as JAVA_HOME. Main difference between PATH and CLASSPATH is that former is used to locate Java commands while later is used to locate Java class files.