简体   繁体   English

在Mac OSX中的Eclipse中缺少JRE

[英]Missing JRE in Eclipse in Mac OSX

I'm trying to run eclipse on my Mac OS X. I've been doing some Android programming on Eclipse lately, and today wanted to do some development on Java. 我正在尝试在Mac OS X上运行eclipse。最近我一直在Eclipse上进行一些Android编程,今天想在Java上进行一些开发。 However, to my surprise, Eclipse says there's no JRE/JDK installed. 但是,令我惊讶的是,Eclipse表示没有安装JRE / JDK。 I don't know how this is possible, since my android projects have worked very well so far, and even now. 我不知道这是怎么可能的,因为到目前为止,即使是现在,我的android项目也运行良好。 I've tried the following items: 我尝试了以下项目:

  • Checking java version through the Mac terminal. 通过Mac终端检查Java版本。 It says java version "1.8.0_20" is installed. 它说已安装java version "1.8.0_20" Here's the screenshot. 这是屏幕截图。 在此处输入图片说明
  • I've checked the Java version through the Java Control Panel in System Preferences. 我已经通过“系统偏好设置”中的“ Java控制面板”检查了Java版本。 Again, same thing: 同样,同一件事: 在此处输入图片说明
  • I know that when there's no JRE visible in Eclipse, it can be manually entered through the "add" option under preferences > Java > Installed JREs in Eclipse. 我知道,当Eclipse中没有可见的JRE时,可以通过“添加”选项在“ 首选项”>“ Java”>“ Eclipse中已安装的JRE ”下手动输入。 But although I can find the Contents folder in this path: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/home/contents , when I attempt to manually add this in Eclipse, the Java folder under users/library just doesn't show up. 但是,尽管我可以在以下路径中找到Contents文件夹: /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/home/contents ,但是当我尝试在Eclipse中手动添加该文件夹时,users / library下的Java文件夹却没有。露面。 I have no idea why this is happening. 我不知道为什么会这样。 Here are some screenshots, just in case: 这是一些屏幕截图,以防万一:

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

在此处输入图片说明

As you can see, the Java folder just doesn't show up under Library in the above screenshot. 如您所见,Java文件夹只是没有显示在上述屏幕快照的“ 库”下。

  • Lastly, I've also tried to hit "Search" in Eclipse (same place as "Add" in one of the screenshots above), but "Search" doesn't find anything at all. 最后,我也尝试在Eclipse中点击“搜索”(与上面的截图之一中的“添加”相同),但是“搜索”根本找不到任何东西。

I've gone through existing answers on SO which deal with similar problems. 我已经解决了类似问题的现有答案。 The only thing which I haven't done seems to be about setting a path variable, but they were all in Windows OS, so not sure if it applies in my situation. 我唯一没有做过的事情似乎是关于设置路径变量,但它们都在Windows OS中,因此不确定它是否适用于我的情况。

I'd really appreciate any help on this. 我真的很感谢任何帮助。


Update 1: According to what has been pointed out so far, I tried copy-pasting the suggested path. 更新1:根据到目前为止所指出的内容,我尝试复制粘贴建议的路径。 But the error I get is: The home directory does not exist. 但是我得到的错误是:主目录不存在。

Here's the screenshot: 这是屏幕截图:

在此处输入图片说明

You are trying to find the JRE in a wrong Library directory as Library directory maybe present in more than one place. 您正在尝试在错误的Library目录中找到JRE,因为Library目录可能存在于多个地方。 Just copy paste the jre path in 'jre home' input as 只需将jre路径复制粘贴为'jre home'输入

/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/home/contents/Home/jre/

在此处输入图片说明

EDIT: To find where is your java installed on Mac, run the following command: 编辑:要查找您的Java在Mac上的安装位置,请运行以下命令:

echo $(/usr/libexec/java_home)

it should return something like this: 它应该返回如下内容:

/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home

append jre to the end of this path to build JRE home path: 将jre附加到此路径的末尾以构建JRE主目录路径:

/Library/Java/JavaVirtualMachines/jdk1.7.0_67.jdk/Contents/Home/jre

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

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