Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CLASSPATH vs PATH

 
wrushasen dakhane
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between "classpath" and "path" variables of the system?
 
Anurag Mishra
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • 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
 
fred rosenberger
lowercase baba
Bartender
Posts: 12083
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
vijaya bharath
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • 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.
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • 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
 
sathish kumar
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
echo %CLASSPATH%
 
Rob Hunter
Ranch Hand
Posts: 832
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
All that did was type %CLASSPATH% on the next line. Anything else I can try? Thanks.

Rob
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15203
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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.
 
Tamil selvan
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • 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"
 
Pravin Jain
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • 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.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic