简体   繁体   中英

How do I install an earlier version of Java SDK on OSX

I have the Java 1.8.0_45 SDK installed on OSX Yosemite (10.10.4), but because of a bug in this release I need to go back to 1.8.0_25

I have downloaded and installed the earlier version (1.8.0_25) but even after a reboot java -version still shows 1.8.0_45.

I don't really understand where Java resides on OSX, but how can I get my system back so it uses 1.8.0_25

Try and add this to your ~/.bashrc

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home

You can have multiple JRE/JDK's installed, by changing this path, you can specify which one you use each time you open a new shell.

Here is what I use in my .bashrc

JAVA_VERSION=7
JAVA_7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home

tmp="JAVA_${JAVA_VERSION}_HOME"
export JAVA_HOME=${!tmp}
export PATH=${!j}/bin:$PATH

Here, you can simply change the 7 to an 8 .

This will change the JAVA_HOME, and append the bin directory to your path for general use from the command line.

note you may beed to change your java home's according to the specific release versions installed on your machine.

Ah found it, suprisingly easy:

macbook:JavaVirtualMachines paul$ cd /Library/Java/JavaVirtualMachines
macbook:JavaVirtualMachines paul$ ls
jdk1.7.0_40.jdk jdk1.7.0_45.jdk jdk1.8.0.jdk    jdk1.8.0_05.jdk jdk1.8.0_20.jdk jdk1.8.0_25.jdk jdk1.8.0_45.jdk
macbook:JavaVirtualMachines paul$ sudo rm -fr jdk1.8.0_45

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