Split rule of args in main function in Java? -
Split rule of args in main function in Java? -
here unusual problem ran into:
i create single programme print received args, here code:
public class test { public static void main(string[] args) { (int = 0; < args.length; ++) { system.out.println(args[i]); } } }
then built jar file of , ran next command:
java -jar test.jar test&1
however, didn't print "test&1" expected. result of is:
test '1'is not recognized internal or external command,operable programme or batch file.
so question is: seperation of args? if need receive "test&1", should do?
thanks!
it's nil java. &
character special windows shell (i can tell it's windows error message): separates 2 commands on 1 line, you're doing telling shell run java -jar test.jar test
, run 1
. if want pass test&1
java, you'll have set in quotes:
java -jar test.jar "test&1"
the &
special on *nix shells (but in different way, runs command in sub-shell). there, utilize quotes above, or set \
before &
instead. not on windows.
java args
Comments
Post a Comment