aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes classpath and Path Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply locked New topic
Author

classpath and Path

Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
can anybody tell me details of classpath and path.?
Are they same or any difference is there?


Tushar
SCJP 5.0
Matthew Plant
Greenhorn

Joined: May 07, 2008
Posts: 18
CLASSPATH is where java applications look to find compiled classes (ie. *.class, *.jar)

PATH is where the system looks to find executables (ie. java.exe, javac.exe) so when you type java from the command line, it can find it and you don't have to change to the correct directory first.
Tusshar Fasate
Ranch Hand

Joined: May 21, 2008
Posts: 81
How can i set path and classpath?
where to set it?
Does classpath come in to picture at runtime only or it plays any role compile time?
Matthew Plant
Greenhorn

Joined: May 07, 2008
Posts: 18
Under Windows, Goto control panel, system, advanced, environment variables. Path and classpath will probably already be under system variables, you can edit these.

classpath maybe set to "." which means the current directory.

you can also set classpath at runtime when you run java.exe by using the command line switch "-cp [classpath]"

If your project uses external jars, you may need to set this switch when you use javac to compile your classes so javac can located the classes within the jar file.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14105
    
  16

Please don't post the same question multiple times.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: classpath and Path