File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes path v classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "path v classpath" Watch "path v classpath" New topic

path v classpath

Ajay srini

Joined: Sep 22, 2008
Posts: 1
Hi all,

I am new to java.
can anyone tell me wat is the difference between path and a class path
and also how to set the both in command prompt.
[ September 22, 2008: Message edited by: David O'Meara ]
Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

The "path" is the path the operating system uses to find execuatables. The "classpath" is the path the JVM's class loader uses to find classes (and other resources). Have a read of our FAQ on the subject.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Jack Leeyohn

Joined: Sep 21, 2008
Posts: 2
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46375
Originally posted by yohn lee:
I think Paul Sturrock's answer was much more useful.

This old thread has details of setting the PATH on Windows from the command line. It would probably be better to add the java part to the beginning of the PATH.

On Linux it varies, but you write something like

export PATH=/usr/bin/java/jdk1.6.0_07/bin/:$PATH

Note the Java entry always ends with "bin".

[edit]Add: You don't usually need to set the classpath as an environment variable[/edit]
[ September 22, 2008: Message edited by: Campbell Ritchie ]
I agree. Here's the link:
subject: path v classpath
It's not a secret anymore!