Split rule of args in main function in Java? -


Here is a strange problem I ran:

Program has been created Args, here is the code:

  test for public class {public static zero main (string [] args) {for (int i = 0; i & lt; args.length ; I ++) {System.out.println (Args [i]); }}}   

Then I created a jar file and run the following command:

  java -jar test.jar test and 1   

However, this does not print as expected "test and 1", the result is:

  test '1' has internal or external commands, operative programs Or is not recognized as a batch file.   

So my question is: What is the separation of Argus? If I really want to get "test and 1", then what should I do?

Thank you!

There is nothing to do with Java & amp; The character is special for the Windows Shell (I can tell it to Windows with the error message) : it separates two rows on one line, so what are you doing Java -jar test.jar test is telling the shell to run and then runs 1 . If you want to go to test & amp; 1, you must put it in quotation marks:

  Java-class test. Judge "Trial and 1"   

& amp; Also, the NIX is special on the sphere (but in a different way, it runs commands in a sub-shell), you can use the quotation given above or instead of & amp; You can insert \ before but not on Windows.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -