英文:
gradle Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'
问题
我根据安装指南正在构建ghidra。
一切进行得很顺利,直到我到达这一步。
一旦我调用$ gradle buildGhidra
,我就会得到以下错误:
> 无法使用工具链“JDK 8(1.8)”定位平台:“Java SE 11”
这看起来很奇怪,因为我确实安装了Java 11:
$ java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment(版本 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM(版本 11.0.8+10-post-Ubuntu-0ubuntu118.04.1,混合模式,共享)
我错过了什么吗?
英文:
- I'm building ghidra according to the installation guide.
Everything goes fine Until I get here. - Once I call
$ gradle buildGhidra
I get the following error:
> Could not target platform: 'Java SE 11' using tool chain: 'JDK 8 (1.8)'
This seems weird because I do have java 11:
$ java --version
openjdk 11.0.8 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)
What am I missing?
答案1
得分: 32
我在尝试通过Intellij使用Gradle构建时遇到了这个问题。
在我的情况下,我安装并在Intellij中配置了两个JDK,JDK1.8和JDK 11。
对于Gradle来说,默认的JVM是采用JDK1.8。
我通过以下步骤解决了这个问题:
- 打开Intellij
- 进入首选项
- 转到“Build, Execution, Deployment” -> “Build Tools” -> “Gradle”
- 搜索“Gradle JVM”。将其更改为所需的JVM
- 尝试重新构建应用程序
英文:
I got this problem when trying to build using gradle through Intellij.
In my case I had two JDK's JDK1.8 and JDK 11 installed and configured in Intellij.
For Gradle it was taking JDK1.8 as default JVM.
I solved the issue using below steps :
- Open Intellij
- Go to Preferences
- Go to "Build, Execution, Deployment" -> "Build Tools" -> Gradle
- Search for "Gradle JVM". Change it to desired JVM
- Try to rebuild the app
答案2
得分: 6
Gradle 使用在您的 JAVA_HOME
环境变量中定义的 Java 发行版,它不会查找路径中的 java 可执行文件。因此,请确保此变量指向有效的 JDK 11 路径。您可以通过运行 gradle --version
来验证是否设置正确,例如:
$ echo %JAVA_HOME%
C:\Work\JDKs\jdk-11.0.8+10
$ gradle --version
------------------------------------------------------------
Gradle 6.6
------------------------------------------------------------
Build time: 2020-08-10 22:06:19 UTC
Revision: d119144684a0c301aea027b79857815659e431b9
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 11.0.8 (AdoptOpenJDK 11.0.8+10)
OS: Windows 10 10.0 amd64
(请注意上面的 JVM 部分。)
英文:
Gradle uses the java distribution defined in your JAVA_HOME
environment variable - it does not look at the java executable in your path. So make sure this variable points to a valid JDK 11 path. You can verify if it is set up correctly by running gradle --version
, e.g.
$ echo %JAVA_HOME%
C:\Work\JDKs\jdk-11.0.8+10
$ gradle --version
------------------------------------------------------------
Gradle 6.6
------------------------------------------------------------
Build time: 2020-08-10 22:06:19 UTC
Revision: d119144684a0c301aea027b79857815659e431b9
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 11.0.8 (AdoptOpenJDK 11.0.8+10)
OS: Windows 10 10.0 amd64
(Notice the JVM part above.)
答案3
得分: 2
你是否在使用集成开发环境(IDE)?请确保在你的Gradle设置中,Gradle使用与你的项目相同的Java版本,你可以在IntelliJ中轻松配置此项。详情请参考:https://www.jetbrains.com/help/idea/gradle-jvm-selection.html#jdk_existing_project
英文:
Are you using an IDE? Make sure that in your Gradle settings, Gradle is using the same java version as your project, this can be easily configured in Intellij https://www.jetbrains.com/help/idea/gradle-jvm-selection.html#jdk_existing_project
答案4
得分: 1
- 原来
gradle
确实 是罪魁祸首。 - 可能类似于这篇帖子,我升级到了gradle-6.7。
- 然后,在不进行任何JAVA_HOME更改的情况下,运行
gradle-6.7 --version
,我得到了:
------------------------------------------------------------
Gradle 6.7-rc-3
------------------------------------------------------------
构建时间: 2020-09-30 19:16:51 UTC
修订版: 836e96a80625c9c48b612e662e3b13bd2e2f4c3b
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) 版本 1.10.8,编译于2020年5月10日
JVM: 11.0.8(Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
操作系统: Linux 5.4.0-48-generic amd64
这可能“证明”了 gradle 的确是罪魁祸首
英文:
- It turns out that
gradle
was after all the one to blame. - Probably similar to this post, I upgraded to gradle-6.7.
- Then, calling
gradle-6.7 --version
, without any JAVA_HOME change whatsoever, I got:
------------------------------------------------------------
Gradle 6.7-rc-3
------------------------------------------------------------
Build time: 2020-09-30 19:16:51 UTC
Revision: 836e96a80625c9c48b612e662e3b13bd2e2f4c3b
Kotlin: 1.3.72
Groovy: 2.5.12
Ant: Apache Ant(TM) version 1.10.8 compiled on May 10 2020
JVM: 11.0.8 (Ubuntu 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OS: Linux 5.4.0-48-generic amd64
Which probably "proves" gradle is indeed the one to blame
答案5
得分: 0
在Jenkinsfile
中将我的代理标签更改为openjdk11
后,这个错误就被修复了。
agent {
label 'openjdk11'
}
英文:
Changing my agent label in the Jenkinsfile
, to openjdk11
fixed this error for me.
agent {
label 'openjdk11'
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论