With a little side of applesauce...

Thursday, April 10, 2008

Java command-line arguments

Aahhhhh!! The heavens have opened... :P So the Java command-line delimiter is whitespace, as per:

That isn't a big surprise. BUT, when I am using a shell script to call /usr/bin/java, the command-line args with double or single quotes are split into:

u '"/home/myuser/Mail/Sent' 'Items"'

Sorry, Java!! I was bad-mouthing you the whole time :P

The fix was alluded to the the FAQ at:
http://tiswww.case.edu/php/chet/bash/FAQ Section E14

Assign the value to a SHELL variable, then quote it in the string passed to Java interpreter. ie:

java MyClass arg1 arg2 arg3 "${MYARG}"

No comments: