I've recently updated my mac to OSX 10.11 (el capitan) and opened up eclipse to run a java project that ran fine yesterday before I updated. I received the error message "Error: could not find or load main class Main", and I've narrowed down the problem to eclipse not being able to find the java executable.
Whenever I go to Preferences -> Java -> Installed JREs it tells me that my old JRE was not found and that it's been deleted. I feel as if this should be as simple as adding a new JRE with the path to my java executable, but here's my problem:
When I run which java
in terminal the output is usr/bin/java
. Using this as the path to my JRE doesn't work... as expected.
So I run ls -l which java
the output is /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
. I Expected this to work, but when I enter this path into eclipse it says the folder does not exist (and I confirmed via terminal, it doesn't exist). I've tried a few other locations in which I find the java executable, but none of them work. I haven't been able to find the correct path to my JRE, which I know is currently installed. How can I find my JRE path?
I was actually looking for the wrong thing, I should have just used the install directory of my JDK:
To fix this I typed in terminal: /usr/libexec/java_home
and copied the output (in my case it was /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home
) to Preferences -> Java -> Installed JREs
within Eclipse. Hope it helps anyone else dealing with this.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.