Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I tell IntelliJ to start gradle with Java 1.6 JDK?

A simple question I couldn't figure out even after hours of trying and searching:

I have both Java 6 and 7 installed.

How do I tell IntelliJ to start Gradle builds with a JDK version 1.6?

No matter what I do, IntelliJ keeps starting my gradle with

"c:\program files\java\jdk1.7.0_10\jre\bin\java" -Dgradle.home=C:\_CODING_\gradle-1.4 [...]

I tried:

  • all project modules are set to use 1.6
  • JAVA_HOME is set to C:\Program Files\Java\jdk1.6.0_38
  • setting IDEA_JDK did nothing
  • gradle -v recognizes 1.6 as its JDK on command line
  • restarting IntelliJ and/or computer didn't change the behavior

Is there a setting somewhere to avoid Java 1.7 from being invoked?

like image 364
Stefan Hoth Avatar asked Mar 25 '13 14:03

Stefan Hoth


1 Answers

... 2.5 years later:

I'm using IntelliJ IDEA 15.0, and I had a similar issue:

This version of IDEA ships bundled with JDK 1.8, and I want to build and run a Gradle project under JDK 1.7

The JDK used by Gradle is configurable in the preferences (may not have been the case earlier):

IDEA > Preferences > Build, Execution, Deployment > Build Tools > Gradle

... under "Use local gradle distribution" you should see the "Gradle JVM" property.

NOTE: in my case, it only appears to have taken effect after a system reboot. Something to try if it doesn't work right away!

like image 93
paulkore Avatar answered Sep 24 '22 23:09

paulkore