Search code examples
windowsjavac

How to run javac with paths as argument that contain white spaces?


I am trying to run the following

javac -Xlint:unchecked -classpath C:/Users/a b/workspace/ @C:/Users/a b/workspace/files_to_compile

but I'm getting a

javac: invalid flag C:/users/a

I've also tried to surround both paths with double quotes but it doesn't seem to help a bit:

javac -Xlint:unchecked -classpath "C:/Users/a b/workspace/" @"C:/Users/a b/workspace/files_to_compile"

What am I doing wrong? This same code worked correctly in other computers (probably because they didn't have any white space in their paths..).

Thanks


Solution

  • I've finally come up with the solution to the issue, and I guess no one here could have guessed it.

    The cue to the answer lies with the fact that the contents of the files list (signaled as @ in the args) generally will have each one of its strings with the initial substring equal to what one passes as both the class path and the @ file.

    so..

    The trouble was never the command line parameters, as suggested, but with the contents of the @ file.

    Each line of the file must be put in its own line, surrounded by quotes, and having into consideration that if you're in windows, you have to put the file names in the form of C:\\a\\b\\c.txt!!!