Reputation: 111
I bought a MacBookPro and I'am newbie with this OS.I downloaded the JDK from Oracle's website and installed it (/Library/Java/JavaVirtualMachines/jdk_1.7...) so everything is fine when I enter "java -version" in Terminal it says : 1.7. But I could not set the 1.7 JRE on Eclipse.When I try to Add the JDK at "Java/InstalledJREs/Add" in Eclipse it doesn't accept the Home directory of jdk_1.7/Contents/Home.. What am I doing wrong, couldn't find the way to solve.
Also After installation of 1.7, eclipse cant compile a simple HelloWorld.java file.It gives error something like; "java.lang.UnixProcess" If I remove the 1.7 it works and "java -version" says 1.6
Upvotes: 5
Views: 20537
Reputation: 411
Note, the -vm MUST be specified BEFORE the -vmargs in the eclipse.ini, like this:
-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/bin
-vmargs
-Dosgi.requiredJavaVersion=1.7
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
To check the VM version: Eclipse -> About -> Installation Details (switch to Configuration tab) shows:
....
-showlocation
-vm
/Library/Java/JavaVirtualMachines/jdk1.8.0_191.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib
Upvotes: 1
Reputation: 769
You need to add the JDK on the eclipse.ini file first. Just go to the eclipse folder and find the eclipse.ini. In the eclipse.ini file there will be a section called -vm Add your path to the JDK there.
Now if you are not aware of the path of your jdk, you can use the below command: /usr/libexec/java_home -v 1.8
Once you have your path. Just paste it in the eclipse.ini. Your eclipse should work now.
Upvotes: 6
Reputation: 29669
After you install Eclipse, it generally maps to a JRE and because a JRE doesn't have the javac compile program, you won't be able to compile code until you first add a JDK runtime environment and then map your project to have that JDK included as a library. One think I also do sometimes is edit the eclipse.ini and add a -vm argument that points to {JDK_HOME}/bin/javaw .
Upvotes: 1