我如何告诉IntelliJ开始使用Java 1.6 JDK的Gradle? [英] How do I tell IntelliJ to start gradle with Java 1.6 JDK?

查看:417
本文介绍了我如何告诉IntelliJ开始使用Java 1.6 JDK的Gradle?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题,即使经过几个小时的尝试和搜索后,我也找不到:



我安装了Java 6和7。



如何告诉IntelliJ以JDK版本1.6启动Gradle构建?



无论我做什么,IntelliJ都会以

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

我试过:


  • 所有项目模块都设置为使用1.6

  • JAVA_HOME 设置为 C:\程序文件\Java\jdk1.6.0_38

  • 设置 IDEA_JDK 不做任何事

  • gradle -v

  • 重新启动IntelliJ和/或计算机不会改变行为



有没有设置某处以避免调用Java 1.7?

解决方案

丹尼斯'a



我有99个问题,但gradle不是一个



我的第一个发现是,实际上不是gradle是问题,但是整个IDE使用Java 7,尽管我的设置另有说明。



我有几个问题需要解决:


  1. Java 7在 C: \Windows\System32\ %PATH%之前选取的<\\ c $ c>%JAVA_HOME% / bin%



    =>删除导致所需的%JAVA_HOME%/ bin / java.exe 被正确拾取

  2. 下一个问题是通过 idea64.exe 仍然使用JDK7,但是我无法找到一种方法来改变这个问题: b b b <> href =http://plugins.jetbrains.com/plugin?pr=idea&pluginId=15 =nofollow noreferre r> SystemProperties
    显示IDE当前使用的所有JAVA-Props
    =>使用 idea.bat 来代替
  3. idea.bat 仍然拒绝使用%JAVA_HOME%,但是使用捆绑的JRE代替(%IDEA_HOME%/ jre

    =>检查bat-file的内容引导我去定义%IDEA_JDK%指向%JAVA_HOME%的解决方案,它是的确是唯一使用捆绑JRE之前检查的变量


  4. 关于设置正确的JDK / JRE以启动IntelliJ有一些奇怪的问题,但它完全可行,无需更改任何属性文件或启动文件,从而使其可以安全地升级。



    奖励提示



    如果您使用的是Windows,并且需要更好的方式来跟踪系统属性,我推荐使用 RapidEE 。它比自Windows 95以来没有改变的丑陋Windows UI要好得多。


    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?

    解决方案

    Although Denis' answer helped me investigate further it wasn't successful at first.

    I've got 99 problems but gradle isn't one

    My first find was that in fact not gradle is the problem but the whole IDE is using Java 7 despite my settings say otherwise.

    I had several issues to fight:

    1. Java 7 installed a copy of java.exe in C:\Windows\System32\ which was picked up earlier in %PATH% than the also set %JAVA_HOME%/bin%

      => removing the copies led to the desired %JAVA_HOME%/bin/java.exe being picked up correctly

    2. Next problem was that starting IntelliJ via the idea64.exe still used the JDK7 and I could not find a way to change that

      => Pro tip in testing that: IDEA Plugin SystemProperties displays all JAVA-Props currently used by the IDE => Use idea.bat instead to have a configurable way instead

    3. idea.bat still refused to use the JDK set in %JAVA_HOME% but used the bundled JRE instead ( %IDEA_HOME%/jre)

      => Checking the content of the bat-file lead me to the solution to define %IDEA_JDK% pointing to %JAVA_HOME% which is indeed the only variable the bat checks before resorting to the bundled JRE

    Final thoughts

    There are some weird issues regarding setting the right JDK/JRE for launching IntelliJ but it's perfectly doable without changing any properties-files or launch-files, thus making it safe for upgrading.

    Bonus tip

    If you are using Windows and need a better way to keep track of System Properties I recommed using RapidEE. It's GUI is wayyy better than the ugly Windows UI which hasn't change since Windows 95.

    这篇关于我如何告诉IntelliJ开始使用Java 1.6 JDK的Gradle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆