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

javac -classpath "white spaces"

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

I have noticed that if I try and use the -classpath option when compiling or running a java application, and if my classpath is something like "c:\Document and Settings\gdboling\My Program..."
I get an error because of the white spaces in the directory names. Is there a work around for this?
[ June 06, 2002: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

Is the command line itself failing, or is the command starting and then barfing on the classpath?
If it's the CLI that's tripping over the space you could try wrapping the parameter in quotes (") which should prevent it from trying to break the parameter at the space. Or, you could always resort to the crappy PROGRA~1 notation for the folders that contain spaces.

[Asking smart questions] [About Bear] [Books by Bear]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
On my Windows ZP system, I experience the same problem which is resolved by enclosing the classpath setting in double quotes. Note that when amending an already established classpath, everything must be surrounded with the double quotes. This is what I'm trying to say:
javac -classpath "%classpath%;SomeAdditionalPaths"
Any luck?

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

Thanks Dirk, i will try that. I think that will work though. It makes sense.
I agree. Here's the link:
subject: javac -classpath "white spaces"
It's not a secret anymore!