CLASSPATH
📌 The CLASSPATH in Java
What is CLASSPATH?
The CLASSPATH is an environment variable that tells the Java compiler (javac) and Java runtime (java) where to find:
-
User-defined classes and packages
-
External
.jarlibraries
🔍 Why Is CLASSPATH Important?
If your .class files or .jar files are not in the current directory, Java needs the CLASSPATH to locate them.
Setting the CLASSPATH Temporarily:
Or use it while running the program:
-cp . tells Java to look for classes in the current directory (.).
⚠️ Common CLASSPATH Issues:
-
“
ClassNotFoundException” when the class isn’t in the path -
Incorrect directory structure (package name must match folder name)
Comments
Post a Comment