I am having difficulties passing JVM arguments in NetBeans to my Gradle project. My previous attempts got no success and maybe someone can help me.
Here is what I have tried so far: I am adding the JVM Argument via right click on project --> Properties --> Build In Tasks --> Run --> Putting the JVM Value in the designated field
-Dtest=mytestvalue
When I run the project afterwards via right click and run it display:
Executing: gradle :run
Arguments: [-PcmdLineArgs=, -c, D:\NetBeansProjects\app\settings.gradle]
JVM Arguments: [-Dtest=mytestvalue]
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:run
10:54:55.899 [main] System.getProperty('test') null
So the arguments are displayed in JVM Arguments: [-Dtest=mytestvalue]
but not transferred to the application it seems and System.getProperty('test')
results in null
. I also tried using custom tasks with the same effect.
If I create a jar file and pass the arguments everything works as expected:
λ java -Dtest=mytestvalue -jar app.jar
System.getProperty('test') mytestvalue
System.getProperty('test') results in mytestvalue.
My current workaround is to set the JVM arguments in the build.gradle file which works fine, but I want to get rid of writing the arguments directly into that file.
I am using Gradle 3.3 and NetBeans 8.2