Proper usage of Java -D command-line parameters -


when passing -d parameter in java, proper way of writing command-line , accessing code?

for example, have tried writing this...

if (system.getproperty("test").equalsignorecase("true")) {    //do } 

and calling this...

java -jar myapplication.jar -dtest="true" 

but receive nullpointerexception. doing wrong?

i suspect problem you've put "-d" after -jar. try this:

java -dtest="true" -jar myapplication.jar 

from command line help:

java [-options] -jar jarfile [args...] 

in other words, way you've got @ moment treat -dtest="true" 1 of arguments pass main instead of jvm argument.

(you should also drop quotes, may work anyway - depends on shell.)


Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -