How can I install an additional java on MacOS? I installed jdk8 and that works fine. But now I need a jdk7 installation for development purposes. When trying to install the old version via DMG file, i get a warning, that there is already a newer version of java installed and the installer quits.
/usr/libexec/java_home -verbose Matching Java Virtual Machines (1): 1.8.0_20, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
How to install jdk7 in addition to this one?
It is very possible to run multiple versions of Java on the same machine so you can run your existing applications and Ignition at the same time.
The cleanest way to manage multiple java versions on Mac is to use Homebrew . And within Homebrew , use: homebrew-cask to install the versions of java. jenv to manage the installed versions of java.
1.2 Use HomeBrew Cask Command To UnInstall JDK. Run homebrew cask command $ brew cask uninstall java to uninstall open JDK 12.0. 1. If you want to uninstall open JDK 8 then run $ brew cask uninstall caskroom/versions/adoptopenjdk8 . Below command uninstall open JDK 12.0.
The cleanest way to manage multiple java versions on Mac is to use Homebrew
.
And within Homebrew
, use:
homebrew-cask
to install the versions of javajenv
to manage the installed versions of javaAs seen on http://hanxue-it.blogspot.ch/2014/05/installing-java-8-managing-multiple.html , these are the steps to follow.
Add the homebrew/cask-versions
tap to homebrew using:
brew tap homebrew/cask-versions
Then you can look at all the versions available:
brew search java
Then you can install the version(s) you like:
brew cask install java7 brew cask install java6
And add them to be managed by jenv as usual.
jenv add <javaVersionPathHere>
I think this is the cleanest & simplest way to go about it.
Another important thing to note, as mentioned in Mac OS X 10.6.7 Java Path Current JDK confusing :
For different types of JDKs or installations, you will have different paths
You can check the paths of the versions installed using
/usr/libexec/java_home -V
, see How do I check if the Java JDK is installed on Mac?On Mac OS X Mavericks, I found as following:
1) Built-in JRE default:
/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
2) JDKs downloaded from Apple:
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/
3) JDKs downloaded from Oracle:
/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
Uninstall jdk8, install jdk7, then reinstall jdk8.
My approach to switching between them (in .profile) :
export JAVA_7_HOME=$(/usr/libexec/java_home -v1.7) export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8) export JAVA_9_HOME=$(/usr/libexec/java_home -v9) alias java7='export JAVA_HOME=$JAVA_7_HOME' alias java8='export JAVA_HOME=$JAVA_8_HOME' alias java9='export JAVA_HOME=$JAVA_9_HOME' #default java8 export JAVA_HOME=$JAVA_8_HOME
Then you can simply type java7
or java8
in a terminal to switch versions.
(edit: updated to add Dylans improvement for Java 9)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With