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 Classpath Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Classpath Question" Watch "Classpath Question" New topic

Classpath Question

Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
I you have the CLASSPATH environment variable set, and also use the -classpath option in the java command, does the -classpath option override the environment varibable paths, or are they both used.
Thanks for the help.
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
I don't know. You could try different settings and see which one works. Let us know what you learn.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
I have tried, seems like a no-brainer to test, but my results have been inconsistent.
Sometimes it looks like it also uses to env variable and sometimes it doesn't.
That is why I wanted to know how it was supposed to work.
Thanks, sorry if it appeared as if I did not even give it a try.
Anyone know the rule?
Barry Andrews
Ranch Hand

Joined: Sep 05, 2000
Posts: 523

From my experience (Windows), java -classpath will override the the system classpath always.

Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9058
The command line option -classpath should always override the environment variables.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Rob Levo
Ranch Hand

Joined: Oct 01, 2000
Posts: 167
I agree. Here's the link:
subject: Classpath Question
It's not a secret anymore!