gradle doesn't work in Intellij - problems with JAVA_HOME

后端 未结 5 1989
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-29 04:58
  • I can run gradle from a command line to see its version.
  • I can run, compile and debug a grails app in IntelliJ (version 10.0 or version 10.2)
  • I insta
相关标签:
5条回答
  • 2020-12-29 05:17

    Point your JAVA_HOME to JDK, not to JRE.

    0 讨论(0)
  • 2020-12-29 05:18

    if you are using Intellij version 10.x you should not install any Plugin to run a gradle script.

    All you have to do is to go to the Gradle setup (File -> Settings -> Gradle) and set the Gradle Home folder (the location of your Gradle installation, eg. C:\tools\gradle).

    You should be able to select a Gradle build file and run it.

    0 讨论(0)
  • 2020-12-29 05:21

    IntelliJ uses its own jre.

    to force IntelliJ to use it, you need to set the environment variable IDEA_JDK to point to your JDK.

    then simply restart intellij and gradle gui plugin should now work.

    0 讨论(0)
  • 2020-12-29 05:24

    Man I had so much trouble with this as well, and I don't remember having this much trouble before. I think they changed something. Here are the incantations which got it working for me on Mac OS X 10.11.5, both with Java and Gradle on IntelliJ 2016.1

    Here's the summary: install the latest Java JDK from Oracle, add the java_home value to $JAVA_HOME and set that value to $IDEA_HOME (IntelliJ's variable for defining which JDK to use), install gradle (optional) using homebrew, then define the project SDK in IntelliJ.

    Here it is broken down from the very beginning of a clean install:

    1. Download Java from Oracle's Download Page

    2. Use homebrew to install gradle

    IntelliJ ships with its own version of Gradle, so this is really optional, and is helpful if you want to use Gradle outside of IntelliJ.

    `brew update && brew install gradle`
    

    3. Set the env variables

    Paste the following into ~/.profile. These values will work regardless of which version of java or gradle you have installed. Don't set the GRADLE_HOME if you didn't install the standalone gradle.

    export JAVA_HOME=$(/usr/libexec/java_home)
    export IDEA_JDK=$JAVA_HOME
    export GRADLE_HOME=/usr/local/opt/gradle/libexec
    

    4. Set the environment variable to occur at application launch so that IntelliJ sees is using OS X's launchctl program:

    launchctl setenv JAVA_HOME $(/usr/libexec/java_home)
    

    5. Define the project SDK

    Use the project settings window in IntelliJ to define the project SDK (I don't see this option anywhere else in the global IntelliJ preferences window, this has to be done in the project settings).

    6. Wait for the indexes to update, then close and re-open IntelliJ. You should now be able to build the program.

    0 讨论(0)
  • 2020-12-29 05:40

    I think this error might be caused by an install bug with IntelliJ IDEA. When I look at the installed folder referred to in the error message on my filesystem:

    C:\Program Files (x86)\JetBrains\IntelliJ IDEA 10.0\jre
    

    I see the jre folder but then another jre folder beneath that one which contains the bin and lib folders of the jre:

    jre
        jre
            bin
            lib
    

    I copied bin and lib up a level into the first jre folder, and that fixed this error for me.

    0 讨论(0)
提交回复
热议问题