I have this bash file:
#/bin/bash
PROP="-Dprop=foo bar"
java $PROP -jar Foo.jar
So, what I want to do here is pass a space-separated list as a System Property. But this somehow does not work:
Caused by: java.lang.ClassNotFoundException: bar
So, it seems that Bash breaks -Dprop=foo bar
up into -Dprop=foo
, bar
. I tried everything from double quoting to escaping the space character but nothing seems to work.
You need to add the quotation marks around the shell script $ variable:
PROP="-Dprop=foo bar"
java "$PROP" -jar Foo.jar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With