Wednesday, 10 February 2016

Difference Between Path and Classpath

Difference Between Path and Classpath

Hello friends; Hitesh is here, Today we will learn some basic points related to difference between path and classpath.

Difference Between Path and Classpath

PATH and CLASSPATH are two environment variable which plays important role on Java development environment.

PATH environment variable is used to locate binary or Java commands required to compile and execute Java program like javac ( java compiler) and java command must be in PATH in order to compile any Java file and run any Java program. 

CLASSPATH is used to find .class file which is loaded by Application ClassLoader. There are three Class loaders that are used to locate and load class files e.g. BootStrap class loader, extension class loader and System or application class loader. out of three, the last class loader is responsible for loading classes from CLASSPATH in Java.

Set path and classpath in java

Command to set PATH in Windows

set PATH=%PATH%;C:\Program Files\Java\JDK1.6.20\bin

Command to set PATH in UNIX/Linux

export PATH = ${PATH}:/opt/Java/JDK1.6.18/bin

Command to set CLASSPATH in windows

set CLASSPATH=%CLASSPATH%;C:\Program Files\Java\JDK1.6.20\lib

Command to set CLASSPATH in Unix/Linux

export CLASSPATH= ${CLASSPATH}:/opt/Java/JDK1.6.18/lib

No comments:

Post a Comment