4

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

2
  • You specify the full JRE path for the installed JREs - something like /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
    – greg-449
    Jun 16, 2014 at 15:46
  • /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home which I am trying but Eclipse says "The Home directory does not exist" I tried several eclipse versions and ADT still same.. Jun 16, 2014 at 16:00

3 Answers 3

6

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. enter image description here

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.

1

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 .

2
  • Wrong, Eclipse has its own compiler. It works perfectly well on a runtime only.
    – Gimby
    Jun 16, 2014 at 15:51
  • Your right, my answer is geared toward either a Linux or Windows perspective. I assumed Eclipse would have similar functionality on a Mac.
    – djangofan
    Jun 16, 2014 at 17:51
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.