# StartScripts : Use environment variables in defaultJvmOpts

**URL:** <https://discuss.gradle.org/t/startscripts-use-environment-variables-in-defaultjvmopts/44039>\
**Category:** Help/Discuss\
**Created:** [October 13, 2022, 12:47pm UTC](https://discuss.gradle.org/t/startscripts-use-environment-variables-in-defaultjvmopts/44039 "2022-10-13T12:47:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mouradxmt](https://avatars.discourse-cdn.com/v4/letter/m/df788c/32.png) [@mouradxmt](https://discuss.gradle.org/u/mouradxmt)\
**Post date:** [October 13, 2022, 12:47pm UTC](https://discuss.gradle.org/t/startscripts-use-environment-variables-in-defaultjvmopts/44039/1 "2022-10-13T12:47:14Z")

</div>

Hello team,  
I was using Gradle 7.1.1 to define defaultJvmOpts using environment variables ($APP\_HOME) but while upgrading to Gradle 7.5.1, this is no longer expanded.  
I am doing something like this :

```gradle
defaultJvmOpts = '-Dlog4j.configurationFile=CUSTOM_APP_HOME/config/log4j2.xml'

```

and replacing CUSTOM\_APP\_HOME with $APP\_HOME in `doLast` , it was working fine with 7.1.1 , but with the upgrade it fails to do so.

Is there any recommendation to use that environment variable inside DEFAULT\_JVM\_OPTS ?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Vampire](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/vampire/32/9082_2.png) [@Vampire](https://discuss.gradle.org/u/Vampire)\
**Post date:** [October 21, 2022, 12:46pm UTC](https://discuss.gradle.org/t/startscripts-use-environment-variables-in-defaultjvmopts/44039/2 "2022-10-21T12:46:35Z")

</div>

The old start script templates allowed some remote code execution and thus were vulnerable.  
They were “improved” to disallow that, which also means that the environment variables do not work like that anymore.  
You could use your own start script templates that allow it though.
