Skip to content
Related Articles
Open in App
Not now

Related Articles

Difference Between Path and ClassPath in Java

Improve Article
Save Article
  • Last Updated : 30 Jan, 2022
Improve Article
Save Article

The ClassPath is a parameter in the Java Virtual Machine(JVM) or the Java compiler that is used by a system or application ClassLoader to locate and load compiled Java bytecodes stored in the “.class” file. On the other hand, The Path is also an environment variable path that behaves as a mediator between the operating system and developer to inform binary file path.


PATH is an environment variable that is used to find and locate binary files like “java” and “javac” and to locate needed executables from the command line or Terminal window. To set the path, we’re supposed to include or mention JDK_HOME/bin directory in a PATH environment variable. The PATH can not be overridden by providing command and PATH is only used by the operation system(OS) to find binary files.


// To set PATH in the window OS.
set PATH=%PATH%;C:\Program Files\Java\JDK1.5.10\bin

// To set PATH in Unix OS
export PATH=${PATH}:/opt/Java/JDK1.5.10/bin 


Classpath is an environment variable that is used by the application ClassLoader or system to locate and load the compiled Java bytecodes stored in the .class file. To set CLASSPATH. the CLASSPATH can be overridden by adding classpath in the manifest file and by using a command like set -classpath. the CLASSPATH is only used by Java ClassLoaders to load class files.


// To set CLASSPATH in window OS.
set CLASSPATH=%CLASSPATH%;C:\Program Files\Java\JDK1.5.10\lib

// To set PATH in Unix OS.
export CLASSPATH=${CLASSPATH}:/opt/Java/JDK1.5.10/lib

The following table demonstrates the difference between a PATH and a CLASSPATH

S. No. 




An environment variable is used by the operating system to find the executable files. An environment variable is used by the Java compiler to find the path of classes.


PATH setting up an environment for the operating system. Operating System will look in this PATH for executables. Classpath setting up the environment for Java. Java will use to find compiled classes.


Refers to the operating system. Refers to the Developing Environment.


In path variable, we must place .\bin folder path  In classpath, we must place .\lib\jar file or directory path in which .java file is available.


PATH is used by CMD prompt to find binary files. CLASSPATH is used by the compiler and JVM to find library files.
My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!