How to run javac with paths as an argument that contains 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 get

javac: invalid flag C:/users/a

I 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? The same code worked correctly on other computers (probably because they did not have spaces in their paths ..).

thank

+5
source share
9 answers

Finally, I came to a solution to the problem, and, I think, no one here could have guessed this.

The key to the answer is that the contents of the file list (denoted by @ in the arguments) will usually contain each of its lines with the original substring equal to the one that passes both the class path and @file.

So..

, , @.

, , , , C:\\a\\b\\c.txt!!!

+4

.

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

, "files_to_compile", :

  • , :\

, .

+4

, , . :

C:\lol > "C:\Program Files\Java\jdk1.7.0_07\bin\javac" -cp "c:\lol\ab; c:\lol\foo bar" Lol.java

:

./foo bar
./foo bar/Moo.java
./Lol.java
./a b
./a b/AB.java

java , : http://www.pvv.ntnu.no/~rakhmato/tmp/lol.tar

@, , , , . Main.java, , .

.bat script . , - :

compile.bat:

"C:\Program Files\Java\jdk1.7.0_07\bin\javac" -classpath "c:\lol\a b; c:\lol\foo bar" Main.java

.. compile.bat CMD

+2
  • cd , .

    cd /home/sayantani/PERSONAL\ FILES/sem\ 4\ courses/PLC/code/
    
  • , "\" , . " " "\".

  • "javac filename.java"

    javac hello1.java
    

. , "javac" . ( )

+2

.

a \ .

0

a b C:/Users/a_b/workspace/" @"C:/Users/a_b/workspace/files_to_compile". , , '\' a\ b

0

, Windows 7, , mklink, , , .

: , :

cd "C:/Users/a b/"
javac ... -classpath "Workspace" ...
0

"java/?"

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC>cd "C:\Program Files (x86)\Java\jre6\bin"

C:\Program Files (x86)\Java\jre6\bin>java.exe
Usage: java [-options] class [args...]
       (to execute a class)
or  java [-options] -jar jarfile [args...]
       (to execute a jar file)

where options include:
-client       to select the "client" VM
-server       to select the "server" VM
-hotspot      is a synonym for the "client" VM  [deprecated]
              The default VM is client.

-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
              A ; separated list of directories, JAR archives,
              and ZIP archives to search for class files.

-classpath , ( ";" ).

0

, ( dmcgil , classpath ):

javac -Xlint:unchecked -classpath C:\Users\a^ b\workspace\;C:\Users\a^ b\workspace\files_to_compile

, escape charachter win .

.

EDIT:

Also, in your question, I noticed the use of slashes (/) in paths, do not all window versions use backslashes (\) as file delimiters? I saw your comment somewhere in this thread, stating exactly this, so I assume that you are sealed in the question.

-1
source

All Articles