How to pass system properties to a jar file

前端 未结 2 1542
不思量自难忘°
不思量自难忘° 2020-12-08 02:11

I have a main class that expects certain properties that I pass using the -D option. I can access this in my IDE by sending them as VM options.

I package this applic

相关标签:
2条回答
  • 2020-12-08 02:28

    Adding to Elliott's answer, if I just run this then I get an error:

    java -Djna.nosys=true -jar jenkins.war
    

    but if I add quotes like this then it works:

    java "-Djna.nosys=true" -jar jenkins.war
    
    0 讨论(0)
  • 2020-12-08 02:29

    Pass the arguments before the -jar. If you pass them after the jar file they are interpreted as command line parameters and passed to the String[] args in main. Like,

    java -Denviroment=dev -jar myjar.jar 
    
    0 讨论(0)
提交回复
热议问题