14

I downloaded JDK for Mac OS X 10.9.1 from Oracle, but I had to install another Java from Apple site once more, as I couldn't launch eclipse with it.

These are two pages that I referred.

Now I have three java binaries installed in my computer.

Installation A

/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

Installation B

/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/java

java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

Installation C

/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)

I found that I can easily remove Installation C, however I'm not sure if this is OK.

When I invoked java from command line, it points to Installation A.

java -version
java version "1.7.0_51"

ls -alF `which java`
lrwxr-xr-x  1 root  wheel  74 Jan 15 09:12 /usr/bin/java@ -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
  • Is there any way to use just one JDK 1.7 for Mavericks by removing two of them safely?

EDIT

After some setup and test, I have only one Java (1.6) installed. I have Installation B, and now Installation C is linked to Installation A.

For using eclipse, I had to make Compiler Compliance level to 1.6 to use it (from the help java.lang.UnsupportedClassVersionError Unsupported major.minor version 51.0).

enter image description here

EDIT2

This seems to what happened.

  1. Installation of Apple Java

    • Installation A
    • Installation B is a symbolic link to A
  2. Installation of Oracle Java

    • Installation C
    • Changed the Installation B that
      1. Created a /System/Library/Frameworks/JavaVM.framework/Versions/A
      2. Copied files from Installation C (not symbolic link)
      3. Make a symlink Current to Versions/A

I tried to install Oracle Java only by removing Apple Java, but I got installation error, so I guess Apple Java is needed to install Oracle Java.

Community
  • 1
  • 1
prosseek
  • 182,215
  • 215
  • 566
  • 871
  • Check [this](http://wiki.eclipse.org/Eclipse.ini) page to tell Eclipse with Java jdk to use. I don't have any suggestion for your other questions. – watery Jan 15 '14 at 20:41
  • What was the original Java issue that you never mentioned? I'm not surprised that two downloads from two different organization installed themselves differently, just that there's no explanation for the third one. – nitind Jan 15 '14 at 20:48

2 Answers2

8

Specify the JVM for Eclipse

You can specify JDK version for usage with Eclipse in eclipse.ini. This will resolve problem with starting Eclipse.

-vm
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java

Warning: Add this configuration before -vmargs.

Master your Java Environnement with jenv

It is much easier to maintain multiple JDK versions with jenv.

jenv is for a equivalent of rbenv, but for Java environnement. It allow to easily switch between several JDKs installations (already presents), and configure which one to use per project.

Eclipse JDK

Community
  • 1
  • 1
MariuszS
  • 30,646
  • 12
  • 114
  • 155
  • I'm not a mac guy, but can you expand upon your answer and explain why its better to manage _development_ JDKs using jenv versus using the tools built into Eclipse to manage development and target JDK/JREs? And, granted I notice that the OP says he can't launch Eclipse with his current system state which is out of context for this group. – Pedantic Jan 16 '14 at 04:21
  • 1
    @Pedantic The question was: *Is there any way to use just one JDK 1.7 for Mavericks by removing two of them safely?* :) Added suggestion for running eclipse with proper JVM – MariuszS Jan 16 '14 at 09:55
  • Thanks :) Wanted to get a mac for various reasons, one of which is for web app dev purposes. Only reason why I chimed in - for history. – Pedantic Jan 17 '14 at 04:15
1

It seems like that the oracle JDK can be just removed. For eclipse, I could add Installation A as a default JRE from Java Build Path -> JRE System Library -> Installed JRES -> Add ...

enter image description here

prosseek
  • 182,215
  • 215
  • 566
  • 871