Labels

Thursday, January 27, 2011

Difference Between PATH And CLASSPATH In Java

PATH:-
It is a system variable used to tell to OS all locations of exec file.

Setting the PATH in Microsoft Windows XP
1) Right click on My Computer
2) Select Properties
3) Select the Advanced tab.
4) Click the Environment Variables button
5) In System Variable section path variable will be present. Click on edit for
modifying it .
enter variable name:CLASSPATH
value should be your path as c:/program files/java/bin and put semicolonat the end.
6) Click ok.
7) Click ok.
8) Click ok.


CLASSPATH:-

It is user management variable, which is used to tell locations of all jar/zip (classes) files to Compiler.



Both PATH and classpath are Environmental variable.

1) Right click on My Computer 4) Select the Advanced tab
2) Select Properties
3) Select the Advanced tab.


5) Click the Environment Variables button
6) Click the New button to create a CLASSPATH or the Edit button to edit an existing CLASSPATH
7) Enter CLASSPATH as the variable name
8) Enter the list of directories or jar files in your CLASSPATH as the variable value, using a semicolon to separate entries in your list.
9) Click OK.
10) Click OK.
11) Click OK.

3 comments:

  1. Hi,

    Its worth noting that if you have two classes with same name in classpath in that case one which comes earlier in classpath will get picked up. this concept is very useful to test patch releases where you update only few classes to quickly test patch release or have added some debug print statement to troubleshoot any issue. to read more about How classpath works in Java

    Thanks
    Javin
    Why String is immutable in Java

    ReplyDelete
  2. Hi Sachin,

    Its worth noting that if you have two classes with same name in classpath in that case one which comes earlier in classpath will get picked up. this concept is very useful to test patch releases where you update only few classes to quickly test patch release or have added some debug print statement to troubleshoot any issue. to read more about How classpath works in Java

    Thanks
    Javin
    Why String is immutable in Java

    ReplyDelete
  3. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanks a million once again, Regards, Difference Classpath and Path

    ReplyDelete