Domanda

I'm new on mac and I need to install both Java 6 and Java 7. My Mac's version is Mac OS X Lion 10.7.5 (11G63)

The problem is I have found already installed Java 7 and I need to install Java 6 and switch between them because I have some projects needed 6 and others need 7. I normally go on oracle web site and download the version's Java that I need to install on Linux or Windows.

The problem is that I couldn't find the version for Mac on http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html#jdk-6u45-oth-JPR

Could someone explain me how I can get Java 6 and how I can switch between them? Thanks a million

È stato utile?

Soluzione

Welcome to Mac world !! You need to download Java from this site and install it on your system. After that, open your terminal and type

javac -version

You will see that it still shows your java version 1.7.

What you need to do next is using java_home to check the path of the java 1.6

$ /usr/libexec/java_home -v 1.6
/Library/Java/JavaVirtualMachines/1.6.0_45-b06-451.jdk/Contents/Home
$ /usr/libexec/java_home -v 1.7
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home

So, whenever you need 1.6 or 1.7, you can set the path of the particular version in /User/<your-account>/.bash_profile. For example:

export JAVA_HOME="/Library/Java/JavaVirtualMachines/1.6.0_45-b06-451.jdk/Contents/Home"
# export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home"
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top