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 list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "-classpath list" Watch "-classpath list" New topic

-classpath list

V Bose
Ranch Hand

Joined: Jul 10, 2003
Posts: 113
How do you specify a list of classpath(s) when invoking the command line javac compiler, with a -classpath switch, in a Windows environment ?
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

Separate each entry with semicolons, like this:
-classpath c:\foo;d:\bar;c:\jars\my.jar;.

[Jess in Action][AskingGoodQuestions]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
For any Linux-using Java greenhorn lurkers out there, note that different locations in the classpath setting are separated with a colon - not with a semicolon as is used on Windows.

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Wayne L Johnson
Ranch Hand

Joined: Sep 03, 2003
Posts: 399
Java is pretty agnostic when it comes to path separators, so you can use either type of slash when specifying a path. Thus you could use:
-classpath c:/foo;d:/bar;c:/jars/my.jar;.
on Windows and it would work just as well. When using file paths in Java, I find it easier to use:
String props = "C:/MyApp/resources/";
String props = "C:\\MyApp\\resources\\";
As I switch between UNIX and Windows, I'm always using the same path separator which keeps things consistent.
[ September 11, 2003: Message edited by: Wayne L Johnson ]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Your post isn't perfectly clear to me.
I'm not a Linux user, I just pretend to give CLASSPATH advice at times.
Someone once told me that the CLASSPATH locations on Linux had to be separated with colons. Is this not the case and we can just use semicolons as with Windows?
I agree. Here's the link:
subject: -classpath list
It's not a secret anymore!