简体   繁体   中英

Java JDK7 on Mac OS X 10.7.3

I've to use OpenJML and that requires Java JDK7. I've installed JDK7 so far following the instructions from this link: http://formalmethods.insttech.washington.edu/software/openjml.html

After the installation my Eclipse project didn't show any errors any more because it found JavaSE7 now.

But when I type java -version in Terminal there is still ...

java version "1.6.0_29"

... displayed there. What can I do to use 1.7 in the shell as well?

First, please uninstall JDK1.6 Need root permisstion:
cd /System/Library/Java/JavaVirtualMachines
rm -rf 1.6.0.jdk/

Second, download from oracle website http://download.oracle.com/otn-pub/java/jdk/7u65-b17/jdk-7u65-macosx-x64.dmg

Third, extract dmg, double click install icon, press 'next' until finish.

eclipse uses the java that is configured in your environmental variables.

not sure how to get there in mac but you should enter these values

Uservariables (create or edit existing):

Variable | Value

JAVA_HOME | Pathto\\Java\\jdk1.7.0_03

Systemvariables(edit+ add, dont delete previous entries!):

Path | Pathto\\Java\\jdk1.7.0_03\\bin

The new JDK will be installed into:

/Library/Java/JavaVirtualMachines

On my Mac with the developer preview installed you can run:

/Library/Java/JavaVirtualMachines/JDK\ 1.7.0\ Developer\ Preview.jdk/Contents/Home/bin/java -version

java version "1.7.0_04-ea"
Java(TM) SE Runtime Environment (build 1.7.0_04-ea-b225)
Java HotSpot(TM) 64-Bit Server VM (build 23.0-b09, mixed mode)

You can select the current system JVM via the Java Preferences application (use spotlight to find it).

Alternatively you can use /usr/libexec/java_home --version 1.7 to find the correct JAVA_HOME value for the requested JDK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM