简体   繁体   English

使用 Gradle 运行 Java 项目时出错——寻找错误的 Java 版本

[英]Error running Java project with Gradle -- Looking for wrong Java version

I have a Java project in Intellij IDEA and am using Gradle as a build tool.我在 Intellij IDEA 中有一个 Java 项目,并且使用 Gradle 作为构建工具。 For whatever reason, when I try to run the project, I am getting this error:无论出于何种原因,当我尝试运行该项目时,出现此错误:

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
> Process 'command '/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1

My current version of Java is 1.8.我当前的 Java 版本是 1.8。 I made sure my JAVA_HOME was set to the 1.8 location.我确保我的 JAVA_HOME 设置为 1.8 位置。 Any help on this would be appreciated.对此的任何帮助将不胜感激。

Intellij and Gradle is little bit tricky: Intellij 和 Gradle 有点棘手:

  1. You can run from console\\terminal您可以从控制台\\终端运行
  2. Also you can run with Intellij UI (aka "play" button)您也可以使用 Intellij UI(又名“播放”按钮)运行

If you are using UI make sure your setup is correct for the gradle:如果您使用 UI,请确保您的设置对于 gradle 是正确的:

On Mac (Similar to Windows):在 Mac 上(类似于 Windows):
Intellij -> Preferences , go to: Build, Execution, Deployment -> Build Tools -> Gradle Intellij -> Preferences ,转到:构建、执行、部署->构建工具-> Gradle 喜好

Make sure:确保:
1. Your Gradle JVM is pointing to current place 1. 你的Gradle JVM指向当前位置
2. (Optional) Make sure you are using correct gradle/wrapper/etc 2.(可选)确保您使用正确的gradle/wrapper/etc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM