# JVM Arguments in NetBeans with gradle

**URL:** <https://discuss.gradle.org/t/jvm-arguments-in-netbeans-with-gradle/21143>\
**Category:** Help/Discuss\
**Created:** [January 13, 2017, 1:16pm UTC](https://discuss.gradle.org/t/jvm-arguments-in-netbeans-with-gradle/21143 "2017-01-13T13:16:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mick99](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mick99](https://discuss.gradle.org/u/mick99)\
**Post date:** [January 13, 2017, 1:16pm UTC](https://discuss.gradle.org/t/jvm-arguments-in-netbeans-with-gradle/21143/1 "2017-01-13T13:16:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mick99](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@mick99](https://discuss.gradle.org/u/mick99)\
**Post date:** [January 13, 2017, 2:13pm UTC](https://discuss.gradle.org/t/jvm-arguments-in-netbeans-with-gradle/21143/2 "2017-01-13T14:13:36Z")

</div>

Thanks to @MarvinFrommhold and his Post [http://stackoverflow.com/a/26141841/7220665](http://stackoverflow.com/a/26141841/7220665) I have finally found what I wanted.

I just had to extend the run task with

```
run {
    systemProperties = System.properties
}

```

and my arguments are passed through to my application where I can use it.
