aspose file tools*
The moose likes Beginning Java and the fly likes CLASSPATH vs PATH Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "CLASSPATH vs PATH" Watch "CLASSPATH vs PATH" New topic
Author

CLASSPATH vs PATH

wrushasen dakhane
Ranch Hand

Joined: Sep 25, 2006
Posts: 47
what is the difference between "classpath" and "path" variables of the system?


SCJP 1.4, SCWCD 1.4
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
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


SCJP 1.2
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11231
    
  16

"path" is used by the Operating System to find executable files.

"classpath" is used by the JVM to find .class files.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
vijaya bharath
Ranch Hand

Joined: Jun 10, 2005
Posts: 66
"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.


Regards,<br />Vijaya Bharath.<br />SCJP1.4 <br />SCWCD5.0
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 818
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

Joined: Feb 14, 2007
Posts: 47
echo %CLASSPATH%
Rob Hunter
Ranch Hand

Joined: Apr 09, 2002
Posts: 818
All that did was type %CLASSPATH% on the next line. Anything else I can try? Thanks.

Rob
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14111
    
  16

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Tamil selvan
Ranch Hand

Joined: Apr 07, 2007
Posts: 69
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"


SCJP 1.4

All the knowledge that the world has ever received comes from the mind; the infinite library of the universe is in your own mind - Swami Vivekananda
Pravin Jain
Ranch Hand

Joined: May 20, 2007
Posts: 60

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.


The Zen of Java Programming.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

You can also type "set classpath" which will display/print the content of environment variable "classpath" if its defined.


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

"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

Joined: May 20, 2007
Posts: 60

"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.
 
 
subject: CLASSPATH vs PATH