• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

CLASSPATH vs PATH

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the difference between "classpath" and "path" variables of the system?
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Path is where all the executable files will reside usually at this location in jdk for example.
\jdk1.5.0_10\bin

Classpath is where all the jar files are placed at this loaction in jdk.
\jdk1.5.0_10\lib
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"path" is used by the Operating System to find executable files.

"classpath" is used by the JVM to find .class files.
 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Path" contains all the binary files of the commands you use to compile the program or to run the program,for example javac and java etc..
"Class path" contains all the classes or packages which you import in your java file, like java.util,java.lang packages etc.
 
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a quick one: typing in Path at the DOS prompt gives everything in the Path variable. How can I find out what's in the Classpath? Thanks.

Rob
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
echo %CLASSPATH%
 
Rob Hunter
Ranch Hand
Posts: 838
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All that did was type %CLASSPATH% on the next line. Anything else I can try? Thanks.

Rob
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rob Hunter:
All that did was type %CLASSPATH% on the next line. Anything else I can try?


That is not because the command is wrong. It means that your CLASSPATH environment variable is not set.
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rob Hunter:
All that did was type %CLASSPATH% on the next line. Anything else I can try? Thanks.

Rob



Hi,

You may be aware of setting the Environment Variable in Windows. However, let me walk you through the procedure to set the CLASSPATH Environment Variable.

1. Right click "My Computer" icon on your desktop (or goto Start-> Control Panel -> System)
2. Select "Properties" on the context menu
3. Click "Advanced" tab on the System Properties box
4. Click "Environment Variables" button at the bottom
5. Click "New" button under "System variables"
6. In the "New System Variable" box:
a) type classpath in the "Variable name" text box
b) type your javaroot installation path with \lib
e.g., c:\jdk1.5.0_10\lib;
7. Click "OK"
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Classpath is where all the jar files are placed at this loaction in jdk.
\jdk1.5.0_10\lib



No, CLASSPATH is the path from where classes are available, which could
a jar file or a directory.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also type "set classpath" which will display/print the content of environment variable "classpath" if its defined.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Path" is during runtime to find the executables which are supporting and necessary to run a file/application.

"Classpath" - as the name indicates, is used during the compilation time to find the necessary .class files irrespective of their location - be it inside a directory, .jar file, .zip file etc.


HtH.
 
Pravin Jain
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


"Classpath" - as the name indicates, is used during the compilation time to find the necessary .class files irrespective of their location - be it inside a directory, .jar file, .zip file etc.



Not only at compile time but also at runtime, it is only that
you don't need it when using Application Servers. But would
be required even at runtime for standalone applications.
 
Destiny's powerful hand has made the bed of my future. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic