[ACCEPTED]-How to pass Properties to jar from Powershell?-properties
Take a look at my answer to this question. Note 4 how you can use echoargs.exe to diagnose 3 these sort of problems. Most likely the 2 fix would be to quote the parameter e.g.:
java -jar "-Duser.language=en" any.jar
You 1 can test that using echoargs (from PowerShell Community Extensions):
echoargs -jar "-Duser.language=en" any.jar
Arg 0 is <-jar>
Arg 1 is <-Duser.language=en>
Arg 2 is <any.jar>
Using quotes works fine for me in PowerShell 4 on Windows 7.
java "-Dmy.property=value" -jar myjar.jar
Be careful: the jar name must 3 be placed right after -jar
, and arguments placed 2 after -jar myjar.jar
will be passed to the program inside the 1 jarFile.
Try launching instead using the following 14 pattern:
java -Duser.language=en -jar any.jar
That assumes that user.language 13 is meant as a system property. If you meant 12 it as a command line argument, change that 11 to:
java -jar any.jar -Duser.language=en
I am actually surprised that the command 10 line you mentioned works at all outside 9 of powershell (though I have confirmed that 8 it works fine for me too, even on Linux) and 7 it is also a little strange that things 6 would work differently inside and outside 5 of powershell.
From java -help
:
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
...
-D<name>=<value>
set a system property
...
So basically you should 4 always put the JAR filename directly after 3 the -jar
command line option, and any JVM options 2 (such as setting system properties with 1 -D
) before.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.