Java – passing space delimited system properties through shell scripts does not work
•
Java
I have this bash file:
#/bin/bash PROP="-Dprop=foo bar" java $PROP -jar Foo.jar
Therefore, what I want to do here is to pass a space - separated list as a system attribute But somehow it didn't work:
Caused by: java.lang.ClassNotFoundException: bar
So bash seems to break - dprop = foo bar up - dprop = foo, bar I tried everything from double quotes to avoiding spatial characters, but it didn't seem to have any effect
Solution
You need to add quotation marks around the shell script $variable:
PROP="-Dprop=foo bar" java "$PROP" -jar Foo.jar
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码