Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
474 views
in Technique[技术] by (71.8m points)

eclipse - Multiple Java installations in Mac OS X Mavericks

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...