eclipse 打开eclipse时出错 - MAC

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/51261226/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:33:21  来源:igfitidea点击:

Error when open eclipse - MAC

eclipseeclipse-pluginedit

提问by Felix Putzenlechner

I have installed eclipse on my iMac and when I try to open it, it gives me this error:

我在 iMac 上安装了 eclipse,当我尝试打开它时,它给了我这个错误:

Failed to find a Main Class in 
"/Applications/Eclipse.app/Contents/MacOS//../Eclipse/ plugins/org.eclipse.equinox.launcher_1.5.0.v20180512-1130.jar".

On my MacBook Pro, everything works fine, but I have done nothing different.

在我的 MacBook Pro 上,一切正常,但我没有做任何不同的事情。

I have checked other posts, but most of them refer to a windows OS. There was an answer which said that it can just open when everything is in an English folder and this is true for me!

我检查了其他帖子,但其中大部分是指 Windows 操作系统。有一个答案说当所有内容都在英文文件夹中时它可以打开,这对我来说是正确的!

Thanking you in advance!

提前致谢!

回答by Akin Williams

I came across this error after installing Eclipse PDT.

安装 Eclipse PDT 后我遇到了这个错误。

  1. Open your terminal and run the version command: java -version.

  2. If your java version is below 1.8, you will have to update your Java Runtime Environment to at least 1.8.0 by installing an updated JDK here.

  3. Then re-run the java version command and your version should be updated.
  4. You should now be able to install and run Eclipse.
  1. 打开终端,运行version命令:java -version

  2. 如果您的 Java 版本低于 1.8,则必须通过在此处安装更新的 JDK 将 Java 运行时环境更新到至少 1.8.0 。

  3. 然后重新运行 java version 命令,你的版本应该更新了。
  4. 您现在应该能够安装和运行 Eclipse。

回答by Tuco

I have the same issue, but on my MacBookPro. I first installed eclipse Photon, which when starting up prompted me to install Java 6, which I did from https://support.apple.com/kb/DL1572?locale=en_US

我有同样的问题,但在我的 MacBookPro 上。我首先安装了 eclipse Photon,它在启动时提示我安装 Java 6,这是我从https://support.apple.com/kb/DL1572?locale=en_US 做的

Then I also installed the latest JRE (jre-8u171-macosx-x64 as of yesterday). When running eclipse again I started getting this error. Then I tried to run from the command line, and got this error:

然后我还安装了最新的 JRE(昨天的 jre-8u171-macosx-x64)。再次运行 eclipse 时,我开始收到此错误。然后我尝试从命令行运行,并收到此错误:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/eclipse/equinox/launcher/Main : Unsupported major.minor version 51.0

When googling that, the answers said that the reason for that is that the Oracle installer does not update the symlink in /usr/bin, which seemed to be confirmed by the fact that running java -version returned this:

在谷歌搜索时,答案说这是因为 Oracle 安装程序没有更新 /usr/bin 中的符号链接,这似乎被运行 java -version 返回的事实所证实:

java -version
java version "1.6.0_65"

The solutions I found for that were not feasible in MacOS starting in version El Capitan, and I am on High Sierra, so I followed the instructions in this postto fix that, and it worked, now I get:

我找到的解决方案在从 El Capitan 版本开始的 MacOS 中是不可行的,而且我在 High Sierra 上,所以我按照这篇文章中的说明来解决这个问题,它奏效了,现在我得到:

java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

After all of this, however, I get the same "Failed to find a Main Class" error on the dialog as reported initially here, and the same "UnsupportedClassVersionError" on the CLI that I had when the system was still on java 6, so now I am still stuck and out of ideas.

然而,在所有这些之后,我在对话框中得到了与最初报告的相同的“无法找到主类”错误,并且在 CLI 上出现了与系统仍在 java 6 上时相同的“UnsupportedClassVersionError”,所以现在我仍然陷入困境,没有想法。

EDIT: FIXED IT!!

编辑:修复它!

I kept thinking that the problem was the java version, it was somehow still using java 6 (which I had installed due to the initial prompt).

我一直认为问题出在 java 版本上,不知何故仍在使用 java 6(由于初始提示我已安装)。

So I followed the instructions hereto remove what I had installed for the alleged java 6 issue. Then I found thispost in the eclipse forums, which stated at the end (comment added by Eric Rizzo on Tue, 14 February 2017 21:56) that this is not an Eclipse message, but rather an OS message, and that one should NOT do that as apple messed things up with that patch. And then it goes to explain that one should install java 8 JDK (NOT just the JRE as I had done). Once I removed Java 6 and installed the full java 8 JDK, it ran fine :)

所以我按照这里的说明删除了我为所谓的 java 6 问题安装的内容。然后我在 eclipse 论坛中找到了这篇文章,该帖子最后指出(Eric Rizzo 在 2017 年 2 月 14 日星期二 21:56 添加的评论)这不是 Eclipse 消息,而是 OS 消息,并且不应该这样做是因为苹果把那个补丁搞砸了。然后它解释说应该安装java 8 JDK(不仅仅是我所做的JRE)。一旦我删除了 Java 6 并安装了完整的 Java 8 JDK,它就运行良好:)

回答by emedinag

You can edit the eclipse.ini with your vm configuration in the beginning of the file

您可以使用文件开头的 vm 配置编辑 eclipse.ini

-vm
/yourJvmPath/jdk-12.0.1.jdk/bin/java

cat /Applications/Eclipse.app/Contents/Eclipse/eclipse.ini

cat /Applications/Eclipse.app/Contents/Eclipse/eclipse.ini

-vm
/Users/SomeUser/jdk-12.0.1.jdk/bin/java
-startup
../Eclipse/plugins/org.eclipse.equinox.launcher_1.5.400.v20190515-0925.jar
--launcher.library
../Eclipse/plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.1.1000.v20190125-2016

PD. It works with ApacheDirectoryStudio for MAC

PD。它适用于 ApacheDirectoryStudio for MAC

回答by Hardeep Singh

This one works for me with MAC OS Mojave. You can download the Java SE Development Kit 8u221 for mac from the below link.

这个对我来说适用于MAC OS Mojave。您可以从以下链接下载适用于 mac 的 Java SE 开发工具包 8u221。

jdk-8u221-macosx-x64.dmg

jdk-8u221-macosx-x64.dmg

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html