Does jar differentiate between program arguments and jvm arguments

1.8k Views Asked by At

I am trying to execute a jar file. It needs both program arguments and the jvm arguments. Do we need to do something different while passing the command line parameters in order for it to be able to differentiate them, or it will be handled automatically?

Currently I am using eclipse IDE, so I can configure it. However it will be finally run using command line only. Please let me know if something needs to be done differently.

2

There are 2 best solutions below

4
On BEST ANSWER

Well, the JVM arguments are typed before using '-D', then after the jar file you'll type your program arguments:

java -Djvm_argument1=XXX -Djvm_argument2=YYY -jar myjar.jar my_argument1 my_argument2
3
On

I assume you're using java -jar file.jar? It's the same as if you used java MainClass. JVM arguments like -ea, -cp, -classpath, -X..., -D..., etc. are targeted to the VM while all other arguments are targeted to your app.