Updating Eclipse Kepler and Fixing its Woes on Mac OS X Yosemite
2014-11-11
tl;dr
- Installing Java 8 on Mac OS X Yosemite
- Updating Eclipse Kepler to work with Java 8
- Fixing
Error: Could not find or load main class packageName.ClassName
- Fixing
No JREs in workspace compatible with specified execution environment: JavaSE-1.8
Dirty Java 8 and Eclipse
Making Eclipse Kepler to work with Java 8 on Mac OS X Yosemite wasn't all that obvious. I guess this is why people hate Eclipse so much. Here are the steps I followed to make Eclipse Kepler to work with Java 8.
- Visit this page.
- Follow the section,
Installing Java™ 8 support for Eclipse Kepler SR2
. - Install Java SE Development Kit 8.
- Follow the subsection,
Use the Eclipse Marketplace to add Java™ 8 support to your Eclipse Kepler SR-2 package
. - If you attempt to create a new project, a new package then a new class with
a
main
function and run it, you might get an error that goes:Error: Could not find or load main class packageName.ClassName
- One of the top hits on Google for this error was this Stackoverflow page.
- When I right-clicked on the project and tried to edit the build path, I kept on
seeing
No JREs in workspace compatible with specified execution environment: JavaSE-1.8
. - To fix this, I found another Stackoverflow page that suggested a solution.
- The problem is how the fuck do you know where Java 8 is? Thankfully, there a
command in terminal you can run
/usr/libexec/java_home -V
. - Look for
"Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home
- Go through the second Stackoverflow page with the newly found location of Java SE 8.
- You should be able to run the example program now.