javagradlebuild.gradle

How do I tell Gradle to use specific JDK version?


I can't figure out to get this working.

Scenario:

What I want

I thought about having the gradle.properties file, defining the variable. Something like

JAVA_HOME_FOR_MY_PROJECT=<path to my desired JDK>

What I don't want

I could live with many suggestions:

Question:

I have more than one JDK7 available and need to point to a special version (minimum JDK_u version).

Any answer is appreciated and I'm thankful for every hint to the right direction.


Solution

  • Two ways

    1. In gradle.properties in the .gradle directory in your HOME_DIRECTORY set org.gradle.java.home=/path_to_jdk_directory

    or:

    1. In your build.gradle

       compileJava.options.fork = true
       compileJava.options.forkOptions.executable = '/path_to_javac'