Gradle fails to work with JDK9

Gradle fails to work with JDK9. The issue is the MaxPermSize option which is ignored by JDK8 but is not accepted by JDK9. How to switch off this option when running gradle or gradlew?

Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the user guide chapter on the daemon at
Please read the following process output to find out more:

Unrecognized VM option 'MaxPermSize=384m’
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I think we have some other issues with JDK9 at this time too: ClassCastException from org.gradle.process.internal.child.BootstrapSecurityManager

Have you tried with --no-daemon?

I raised GRADLE-3286

Hi Russel,

I had a similar problem with the Groovy build, which is ran against multiple JDKs (5 to 9), and some of them require the MaxPermSize value and some other not. In the end, what I did is pretty simple: the options are specified in

Then when a JDK 9 build is started, before running Gradle, there’s a build step which filters out the MaxPermSize parameter from this line. From my perspective, it means that just having a file that sets org.gradle.jvmargs without MaxPermSize is enough,

OK, so putting:

org.gradle.jvmargs =

in ~/gradle/ gets rid of the problem, so I am OK. On the other hand this is getting rid of all the mx options as well. For JDK8 onwards CMS options are a waste of time (due to G1), but if Gradle needs values for mx, ms, etc. I am not getting them.

As far as I know you can still put Xmx/Xms in the jvmargs. Only make sure you don’t add MaxPermSize.

Indeed, the question was really what are the right values, or whether the defaults for the JVM are now entirely reasonable given we are talking of JDK8 and JDK9.

According to Where Has the Java PermGen Gone?

MaxPerGen is no more after Java 8 but it was replaced.

It may be useful to look at setting it’s replacement MetaspaceSize.

That link results in a 404. Yes PermGen is gone from JDK8 onwards, but I think the idea is to leave G1 to sort things out and avoid any setting of JVM parameters unless absolutely necessary.

There is also a ‘+IgnoreUnrecognizedVMOptions’ vm argument: