Header Ads

Difference Between Path And Classpath In Java

Let us understand what is path in java..
In java path is the variable which holds the specific location of the binary executable files of java like- java/javac etc

How to set path--
Well there are two ways by which we can set path
  • Permanently set path via environment variable-(click here for more)
  • Temporary for a session.
we will check out how to set path temporarily ..

Temporary settings:
1. Go to start-->run -->type cmd
2. click on ok. It will open command prompt for windows

3. Now navigate to the path where you have installed your java(JDK installation folder)
it might be C:\Program Files\java\jdk<<version>>\
4. Copy the path and come back to command prompt.
5. Type the below written command:

set path=C:\Program Files\Java\jdk1.7.0_21\bin\


you are done!! Now you can write any java program and compile the same.


Classpath is the variable which is used to tell JVM from where all my classes are residing. and from which location it has to pick the required .class files.
How to set classpath:
Please go through ..
1. http://www.mydigitalvoice.in/2012/01/setting-class-path-in-java-in-windows.html
   for permanent settings
2. http://www.mydigitalvoice.in/2013/05/what-is-classpath-and-how-to-set-that.html
   for temporary settings

Powered by Blogger.