How do I tell Gradle to use specific JDK version?

前端 未结 17 2174
时光取名叫无心
时光取名叫无心 2020-11-22 12:12

I can\'t figure out to get this working.

Scenario:

  • I have an application built with gradle
  • The application uses JavaFX

What I w

相关标签:
17条回答
  • 2020-11-22 12:17

    I added this line in my GRADLE_HOME/bin/gradle file - export JAVA_HOME=/path/to/java/version

    0 讨论(0)
  • 2020-11-22 12:20

    For windows run gradle task with jdk 11 path parameter in quotes

    gradlew clean build -Dorg.gradle.java.home="c:/Program Files/Java/jdk-11"
    
    0 讨论(0)
  • 2020-11-22 12:20

    If you have this problem from Intellij, try this options

    1. Set Gradle JVM Home

    2. Set the JDK version in the Project module settings

    0 讨论(0)
  • 2020-11-22 12:20

    As seen in Gradle (Eclipse plugin)

    http://www.gradle.org/get-started

    Gradle uses whichever JDK it finds in your path (to check, use java -version). Alternatively, you can set the JAVA_HOME environment variable to point to the install directory of the desired JDK.


    If you are using this Eclipse plugin or Enide Studio 2014, alternative JAVA_HOME to use (set in Preferences) will be in version 0.15, see http://www.nodeclipse.org/history

    0 讨论(0)
  • 2020-11-22 12:21

    If you add JDK_PATH in gradle.properties your build become dependent on on that particular path. Instead Run gradle task with following command line parametemer

    gradle build -Dorg.gradle.java.home=/JDK_PATH
    

    This way your build is not dependent on some concrete path.

    0 讨论(0)
  • 2020-11-22 12:22

    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'
      
    0 讨论(0)
提交回复
热议问题