Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set java system properties in IntelliJ or Eclipse

I have a project which runs correctly under the terminal command

mvn package exec:java -Dplatform.dependencies -Dexec.mainClass=Demo

Now, I need to debug it correctly (not terminal) with IntelliJ or Eclipse on Mac (preferably IntelliJ) but I have tried setting VM options in various places and nothing seems to work.

Where is the correct place to put these options: -Dplatform.dependencies -Dexec.mainClass=Demo?

like image 895
diegomontoyas Avatar asked Apr 05 '15 05:04

diegomontoyas


People also ask

How do I set system properties in IntelliJ?

What you can do is to go to Run -> Edit Configurations -> Defaults -> JUnit ; now add that property there to the VM options . Now every junit test you run will have that property defined.

Where Java system properties are stored?

properties file located in users->appdata->locallow->sun->java>deployment and also directly putting key=value in runtime parameter in java control panel but not working.


2 Answers

In IntelliJ it works as follows: Go to configurations -> VM options and add the parameter/value pair:

-DmyParameter=value

Make sure you add a "D" after the "-"!

enter image description here

like image 77
ShadowGames Avatar answered Oct 19 '22 02:10

ShadowGames


In InteliJ goto "Run"->"Edit Configurations" In the new window, right panel, open the Junit and click on your test. Now, in the middle click on the "Configuration" tab and update the "VM options"

Note that you will need to do this for every test class, but you can remove all the test from the junit in the right panel and update it in the "Defaults"

like image 47
Mzf Avatar answered Oct 19 '22 02:10

Mzf