Java Plug-in technology, included as part of the Java 2 Runtime Environment, Standard Edition (JRE), establishes a connection between popular browsers and the Java platform. Java allows applications to be downloaded over a network and run within a guarded sandbox. Global Nav Open Menu Global Nav Close Menu; Apple; Shopping Bag +. We don't have any change log information yet for version 1.8.11.12 of Java SE 8 Environment 8. Sometimes publishers take a little while to make this information available, so please check back in a few days to see if it has been updated. Download Java for OS X directly from Oracle. Get the latest version If an app or webpage you want to use asks you to install Java software, you can download the current version of Java for OS X directly from Oracle's website.
Question or issue on macOS:
I want to install OpenJDK Java on Mac OSX and have it work alongside other JDK's since it is a newer release. Currently, I downloaded the tar.gz and placed it in my path but that is hard to maintain.
The only other install I found that do more things automatically is the install via Homebrew cask. It looks like only the current version too:
Shows:
So I can install it from there, but then what? Am I stuck only with the new version?
How to solve this problem?
Solution no. 1:
Note:These solutions work for various versions of Java including Java 8, Java 11, and the new Java 15, and for any other previous Java version covered by the listed version managers. This includes alternative JDK's from OpenJDK, Oracle, IBM, Azul, Amazon Correto, Graal and more. Easily work with Java 7, Java 8, Java 9, Java 10, Java 11, Java 12, Java 13, Java 14, and Java 15!
You have a few options for how to do the installation as well as manage JDK switching. Installation can be done by Homebrew, SDKMAN, Jabba, or a manual install. Switching can be done by JEnv, SDKMAN, Jabba, or manually by setting JAVA_HOME
. All of these are described below.
Installation
First, install Java using whatever method you prefer including Homebrew, SDKMAN or a manual install of the tar.gz file. The advantage of a manual install is that the location of the JDK can be placed in a standardized location for Mac OSX. Otherwise, there are easier options such as SDKMAN that also will install other important and common tools for the JVM.
Installing and Switching versions with SDKMAN
SDKMAN is a bit different and handles both the install and the switching. SDKMAN also places the installed JDK's into its own directory tree, which is typically ~/.sdkman/candidates/java
. SDKMAN allows setting a global default version, and a version specific to the current shell.
Install SDKMAN from https://sdkman.io/install
List the Java versions available to make sure you know the version ID
Install one of those versions, for example, Java 15:
Make 15 the default version:
Or switch to 15 for the session:
When you list available versions for installation using the list command, you will see a wide variety of distributions of Java:
And install additional versions, such as JDK 8:
SDKMAN can work with previously installed existing versions. Fl studio free. download full version mac. Just do a local install giving your own version label and the location of the JDK:
And use it freely:
More information is available in the SDKMAN Usage Guide along with other SDK's it can install and manage.
SDKMAN will automatically manage your PATH
and JAVA_HOME
for you as you change versions.
Download OpenJDK for Mac OSX from http://jdk.java.net/ (for example Java 15)
Unarchive the OpenJDK tar, and place the resulting folder (i.e.
jdk-15.jdk
) into your/Library/Java/JavaVirtualMachines/
folder since this is the standard and expected location of JDK installs. You can also install anywhere you want in reality.
Java 1.8 Update 77
Install with HomebrewThe version of Java available in Homebrew Cask previous to October 3, 2018 was indeed the Oracle JVM. Now, however, it has now been updated to OpenJDK. Be sure to update Homebrew and then you will see the lastest version available for install.
Download Java Version 1.8.0_77 Macromedia
install Homebrew if you haven't already. Make sure it is updated:
Add the casks tap, if you want to use the AdoptOpenJDK versions (which tend to be more current):
These casks change their Java versions often, and there might be other taps out there with additional Java versions.
Look for installable versions:
or for AdoptOpenJDK versions:
Check the details on the version that will be installed:
or for the AdoptOpenJDK version:
Install a specific version of the JDK such as
java11
,adoptopenjdk8
, oradoptopenjdk13
, or justjava
oradoptopenjdk
for the most current of that distribution. For example:
And these will be installed into /Library/Java/JavaVirtualMachines/
which is the traditional location expected on Mac OSX.
Some other flavours of OpenJDK are:
Azul Systems Java Zulu certified builds of OpenJDK can be installed by following the instructions on their site.
Zulu® is a certified build of OpenJDK that is fully compliant with the Java SE standard. Zulu is 100% open source and freely downloadable. Now Java developers, system administrators, and end-users can enjoy the full benefits of open source Java with deployment flexibility and control over upgrade timing.
Amazon Correto OpenJDK builds have an easy to use an installation package for Java 8 or Java 11, and installs to the standard /Library/Java/JavaVirtualMachines/
directory on Mac OSX.
Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that will include performance enhancements and security fixes. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard. With Corretto, you can develop and run Java applications on popular operating systems, including Linux, Windows, and macOS.
Where is my JDK?!?!
To find locations of previously installed Java JDK's installed at the default system locations, use:
Matching Java Virtual Machines (8):
15, x86_64: 'OpenJDK 15' /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
14, x86_64: 'OpenJDK 14' /Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home
13, x86_64: 'OpenJDK 13' /Library/Java/JavaVirtualMachines/openjdk-13.jdk/Contents/Home
12, x86_64: 'OpenJDK 12' /Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
11, x86_64: 'Java SE 11' /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
10.0.2, x86_64: 'Java SE 10.0.2' /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
9, x86_64: 'Java SE 9' /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
1.8.0_144, x86_64: 'Java SE 8' /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
You can also report just the location of a specific Java version using -v
. For example for Java 15:
/Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
Knowing the location of the installed JDK's is also useful when using tools like JEnv, or adding a local install to SDKMAN, or linking a system JDK in Jabba — and you need to know where to find them.
If you need to find JDK's installed by other tools, check these locations:
- SDKMAN installs to
~/.sdkman/candidates/java/
- Jabba installs to
~/.jabba/jdk
Switching versions manually
The Java executable is a wrapper that will use whatever JDK is configured in JAVA_HOME
, so you can change that to also change which JDK is in use.
For example, if you installed or untar'd JDK 15 to /Library/Java/JavaVirtualMachines/jdk-15.jdk
if it is the highest version number it should already be the default, if not you could simply set:
And now whatever Java executable is in the path will see this and use the correct JDK.
Using the /usr/libexec/java_home
utility as previously described helps you to create aliases or to run commands to change Java versions by identifying the locations of different JDK installations. For example, creating shell aliases in your .profile
or .bash_profile
to change JAVA_HOME
for you:
Then to change versions, just use the alias.
java version '1.8.0_144'
Of course, setting JAVA_HOME
manually works too!
Switching versions with JEnv
JEnv expects the Java JDK's to already exist on the machine and can be in any location. Typically you will find installed Java JDK's in /Library/Java/JavaVirtualMachines/
. JEnv allows setting the global version of Java, one for the current shell, and a per-directory local version which is handy when some projects require different versions than others.
Install JEnv if you haven't already, instructions on the site http://www.jenv.be/ for manual install or using Homebrew.
Add any Java version to JEnv (adjust the directory if you placed this elsewhere):
Set your global version using this command:
You can also add other existing versions using jenv add
in a similar manner, and list those that are available. For example Java 8:
See the JEnv docs for more commands. You may now switch between any Java versions (Oracle, OpenJDK, other) at any time either for the whole system, for shells, or per local directory.
To help manage JAVA_HOME
while using JEnv you can add the export plugin to do this for you.
The export plugin may not adjust JAVA_HOME
if it is already set, so you may need to clear this variable in your profile so that it can be managed by JEnv.
You can also use jenv exec
to run single commands with JAVA_HOME
and PATH
set correctly for that one command, which could include opening another shell.
Installing and Switching versions with Jabba
Jabba also handles both the install and the switching. Jabba also places the installed JDK's into its own directory tree, which is typically ~/.jabba/jdk
.
Java download for mac fail. Install Jabba by following the instructions on the home page.
List available JDK's
jabba ls-remote
Install Java JDK 12
jabba install [email protected]
Use it:
jabba use [email protected]
You can also alias version names, link to existing JDK's already installed, and find a mix of interesting JDK's such as GraalVM, Adopt JDK, IBM JDK, and more. The complete usage guide is available on the home page as well.
Jabba will automatically manage your PATH
and JAVA_HOME
for you as you change versions.
Solution no. 2:
This is how I did it.
Step 1: Install Java 11
You can download Java 11 dmg for mac from here: https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
Step 2: After installation of Java 11. Confirm installation of all versions. Type the following command in your terminal.
Step 3: Edit .bash_profile
Step 4: Add 11.0.1 as default. (Add below line to bash_profile file).
to switch to any version
Now Press CTRL+X to exit the bash. Press ‘Y' to save changes.
Step 5: Reload bash_profile
Step 6: Confirm current version of Java
Solution no. 3:
Manually switching system-default version without 3rd party tools:
As detailed in this older answer, on macOS /usr/bin/java
is a wrapper tool that will use Java version pointed by JAVA_HOME
or if that variable is not set will look for Java installations under /Library/Java/JavaVirtualMachines/
and will use the one with highest version. It determines versions by looking at Contents/Info.plist
under each package.
Armed with this knowledge you can:
- control which version the system will use by renaming
Info.plist
in versions you don't want to use as default (that file is not used by the actual Java runtime itself). - control which version to use for specific tasks by setting
$JAVA_HOME
I've just verified this is still true with OpenJDK & Mojave.
On a brand new system, there is no Java version installed:
Cancel this, download OpenJDK 11 & 12ea on https://jdk.java.net ;
install OpenJDK11:
System java is now 11:
Install OpenJDK12 (early access at the moment):
System java is now 12:
Now let's 'hide' OpenJDK 12 from system java wrapper:
System java is back to 11:
And you can still use version 12 punctually by manually setting JAVA_HOME
:
Solution no. 4:
With Homebrew and jenv:
Assumption: Mac machine and you already have installed homebrew.
Install cask:
To install latest java:
To install java 8:
To install java 9:
If you want to install/manage multiple version then you can use ‘jenv':
Install and configure jenv:
Add the installed java to jenv:
To see all the installed java:
Above command will give the list of installed java:
Configure the java version which you want to use:
Solution no. 5:
If you have multiple versions installed on your machine, add the following in bash profile:
export JAVA_HOME_7=$(/usr/libexec/java_home -v1.7)
export JAVA_HOME_8=$(/usr/libexec/java_home -v1.8)
export JAVA_HOME_9=$(/usr/libexec/java_home -v9)
And add the following aliases:
alias java7='export JAVA_HOME=$JAVA_HOME_7′
alias java8='export JAVA_HOME=$JAVA_HOME_8′
alias java9='export JAVA_HOME=$JAVA_HOME_9′
And can switch to required version by using the alias:
In terminal:
~ >> java7
export JAVA_HOME=$JAVA_7_HOME
Solution no. 6:
Another alternative is using SDKMAN! See https://wimdeblauwe.wordpress.com/2018/09/26/switching-between-jdk-8-and-11-using-sdkman/
First install SDKMAN: https://sdkman.io/install and then…
- Install Oracle JDK 8 with:
sdk install java 8.0.181-oracle
- Install OpenJDK 11 with:
sdk install java 11.0.0-open
To switch:
- Switch to JDK 8 with
sdk use java 8.0.181-oracle
- Switch to JDK 11 with
sdk use java 11.0.0-open
To set a default:
- Default to JDK 8 with
sdk default java 8.0.181-oracle
- Default to JDK 11 with
sdk default java 11.0.0-open
Solution no. 7:
You can use asdf to install and switch between multiple java versions. It has plugins for other languages as well. You can install asdf with Homebrew
When asdf is configured, install java plugin
Pick a version to install
For example to install and configure adoptopenjdk8
And finally if needed, configure JAVA_HOME for your shell. Just add to your shell init script such as ~/.zshrc in case of zsh:
Solution no. 8:
IMHO, There is no need to install all the additional applications/packages.
The only other install I found that do more things automatically is the install via Homebrew cask. It looks like only the current version too:
Shows:
So I can install it from there, but then what? Am I stuck only with the new version?
How to solve this problem?
Solution no. 1:
Note:These solutions work for various versions of Java including Java 8, Java 11, and the new Java 15, and for any other previous Java version covered by the listed version managers. This includes alternative JDK's from OpenJDK, Oracle, IBM, Azul, Amazon Correto, Graal and more. Easily work with Java 7, Java 8, Java 9, Java 10, Java 11, Java 12, Java 13, Java 14, and Java 15!
You have a few options for how to do the installation as well as manage JDK switching. Installation can be done by Homebrew, SDKMAN, Jabba, or a manual install. Switching can be done by JEnv, SDKMAN, Jabba, or manually by setting JAVA_HOME
. All of these are described below.
Installation
First, install Java using whatever method you prefer including Homebrew, SDKMAN or a manual install of the tar.gz file. The advantage of a manual install is that the location of the JDK can be placed in a standardized location for Mac OSX. Otherwise, there are easier options such as SDKMAN that also will install other important and common tools for the JVM.
Installing and Switching versions with SDKMAN
SDKMAN is a bit different and handles both the install and the switching. SDKMAN also places the installed JDK's into its own directory tree, which is typically ~/.sdkman/candidates/java
. SDKMAN allows setting a global default version, and a version specific to the current shell.
Install SDKMAN from https://sdkman.io/install
List the Java versions available to make sure you know the version ID
Install one of those versions, for example, Java 15:
Make 15 the default version:
Or switch to 15 for the session:
When you list available versions for installation using the list command, you will see a wide variety of distributions of Java:
And install additional versions, such as JDK 8:
SDKMAN can work with previously installed existing versions. Fl studio free. download full version mac. Just do a local install giving your own version label and the location of the JDK:
And use it freely:
More information is available in the SDKMAN Usage Guide along with other SDK's it can install and manage.
SDKMAN will automatically manage your PATH
and JAVA_HOME
for you as you change versions.
Download OpenJDK for Mac OSX from http://jdk.java.net/ (for example Java 15)
Unarchive the OpenJDK tar, and place the resulting folder (i.e.
jdk-15.jdk
) into your/Library/Java/JavaVirtualMachines/
folder since this is the standard and expected location of JDK installs. You can also install anywhere you want in reality.
Java 1.8 Update 77
Install with HomebrewThe version of Java available in Homebrew Cask previous to October 3, 2018 was indeed the Oracle JVM. Now, however, it has now been updated to OpenJDK. Be sure to update Homebrew and then you will see the lastest version available for install.
Download Java Version 1.8.0_77 Macromedia
install Homebrew if you haven't already. Make sure it is updated:
Add the casks tap, if you want to use the AdoptOpenJDK versions (which tend to be more current):
These casks change their Java versions often, and there might be other taps out there with additional Java versions.
Look for installable versions:
or for AdoptOpenJDK versions:
Check the details on the version that will be installed:
or for the AdoptOpenJDK version:
Install a specific version of the JDK such as
java11
,adoptopenjdk8
, oradoptopenjdk13
, or justjava
oradoptopenjdk
for the most current of that distribution. For example:
And these will be installed into /Library/Java/JavaVirtualMachines/
which is the traditional location expected on Mac OSX.
Some other flavours of OpenJDK are:
Azul Systems Java Zulu certified builds of OpenJDK can be installed by following the instructions on their site.
Zulu® is a certified build of OpenJDK that is fully compliant with the Java SE standard. Zulu is 100% open source and freely downloadable. Now Java developers, system administrators, and end-users can enjoy the full benefits of open source Java with deployment flexibility and control over upgrade timing.
Amazon Correto OpenJDK builds have an easy to use an installation package for Java 8 or Java 11, and installs to the standard /Library/Java/JavaVirtualMachines/
directory on Mac OSX.
Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that will include performance enhancements and security fixes. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard. With Corretto, you can develop and run Java applications on popular operating systems, including Linux, Windows, and macOS.
Where is my JDK?!?!
To find locations of previously installed Java JDK's installed at the default system locations, use:
Matching Java Virtual Machines (8):
15, x86_64: 'OpenJDK 15' /Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
14, x86_64: 'OpenJDK 14' /Library/Java/JavaVirtualMachines/jdk-14.jdk/Contents/Home
13, x86_64: 'OpenJDK 13' /Library/Java/JavaVirtualMachines/openjdk-13.jdk/Contents/Home
12, x86_64: 'OpenJDK 12' /Library/Java/JavaVirtualMachines/jdk-12.jdk/Contents/Home
11, x86_64: 'Java SE 11' /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
10.0.2, x86_64: 'Java SE 10.0.2' /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home
9, x86_64: 'Java SE 9' /Library/Java/JavaVirtualMachines/jdk-9.jdk/Contents/Home
1.8.0_144, x86_64: 'Java SE 8' /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
You can also report just the location of a specific Java version using -v
. For example for Java 15:
/Library/Java/JavaVirtualMachines/jdk-15.jdk/Contents/Home
Knowing the location of the installed JDK's is also useful when using tools like JEnv, or adding a local install to SDKMAN, or linking a system JDK in Jabba — and you need to know where to find them.
If you need to find JDK's installed by other tools, check these locations:
- SDKMAN installs to
~/.sdkman/candidates/java/
- Jabba installs to
~/.jabba/jdk
Switching versions manually
The Java executable is a wrapper that will use whatever JDK is configured in JAVA_HOME
, so you can change that to also change which JDK is in use.
For example, if you installed or untar'd JDK 15 to /Library/Java/JavaVirtualMachines/jdk-15.jdk
if it is the highest version number it should already be the default, if not you could simply set:
And now whatever Java executable is in the path will see this and use the correct JDK.
Using the /usr/libexec/java_home
utility as previously described helps you to create aliases or to run commands to change Java versions by identifying the locations of different JDK installations. For example, creating shell aliases in your .profile
or .bash_profile
to change JAVA_HOME
for you:
Then to change versions, just use the alias.
java version '1.8.0_144'
Of course, setting JAVA_HOME
manually works too!
Switching versions with JEnv
JEnv expects the Java JDK's to already exist on the machine and can be in any location. Typically you will find installed Java JDK's in /Library/Java/JavaVirtualMachines/
. JEnv allows setting the global version of Java, one for the current shell, and a per-directory local version which is handy when some projects require different versions than others.
Install JEnv if you haven't already, instructions on the site http://www.jenv.be/ for manual install or using Homebrew.
Add any Java version to JEnv (adjust the directory if you placed this elsewhere):
Set your global version using this command:
You can also add other existing versions using jenv add
in a similar manner, and list those that are available. For example Java 8:
See the JEnv docs for more commands. You may now switch between any Java versions (Oracle, OpenJDK, other) at any time either for the whole system, for shells, or per local directory.
To help manage JAVA_HOME
while using JEnv you can add the export plugin to do this for you.
The export plugin may not adjust JAVA_HOME
if it is already set, so you may need to clear this variable in your profile so that it can be managed by JEnv.
You can also use jenv exec
to run single commands with JAVA_HOME
and PATH
set correctly for that one command, which could include opening another shell.
Installing and Switching versions with Jabba
Jabba also handles both the install and the switching. Jabba also places the installed JDK's into its own directory tree, which is typically ~/.jabba/jdk
.
Java download for mac fail. Install Jabba by following the instructions on the home page.
List available JDK's
jabba ls-remote
Install Java JDK 12
jabba install [email protected]
Use it:
jabba use [email protected]
You can also alias version names, link to existing JDK's already installed, and find a mix of interesting JDK's such as GraalVM, Adopt JDK, IBM JDK, and more. The complete usage guide is available on the home page as well.
Jabba will automatically manage your PATH
and JAVA_HOME
for you as you change versions.
Solution no. 2:
This is how I did it.
Step 1: Install Java 11
You can download Java 11 dmg for mac from here: https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html
Step 2: After installation of Java 11. Confirm installation of all versions. Type the following command in your terminal.
Step 3: Edit .bash_profile
Step 4: Add 11.0.1 as default. (Add below line to bash_profile file).
to switch to any version
Now Press CTRL+X to exit the bash. Press ‘Y' to save changes.
Step 5: Reload bash_profile
Step 6: Confirm current version of Java
Solution no. 3:
Manually switching system-default version without 3rd party tools:
As detailed in this older answer, on macOS /usr/bin/java
is a wrapper tool that will use Java version pointed by JAVA_HOME
or if that variable is not set will look for Java installations under /Library/Java/JavaVirtualMachines/
and will use the one with highest version. It determines versions by looking at Contents/Info.plist
under each package.
Armed with this knowledge you can:
- control which version the system will use by renaming
Info.plist
in versions you don't want to use as default (that file is not used by the actual Java runtime itself). - control which version to use for specific tasks by setting
$JAVA_HOME
I've just verified this is still true with OpenJDK & Mojave.
On a brand new system, there is no Java version installed:
Cancel this, download OpenJDK 11 & 12ea on https://jdk.java.net ;
install OpenJDK11:
System java is now 11:
Install OpenJDK12 (early access at the moment):
System java is now 12:
Now let's 'hide' OpenJDK 12 from system java wrapper:
System java is back to 11:
And you can still use version 12 punctually by manually setting JAVA_HOME
:
Solution no. 4:
With Homebrew and jenv:
Assumption: Mac machine and you already have installed homebrew.
Install cask:
To install latest java:
To install java 8:
To install java 9:
If you want to install/manage multiple version then you can use ‘jenv':
Install and configure jenv:
Add the installed java to jenv:
To see all the installed java:
Above command will give the list of installed java:
Configure the java version which you want to use:
Solution no. 5:
If you have multiple versions installed on your machine, add the following in bash profile:
export JAVA_HOME_7=$(/usr/libexec/java_home -v1.7)
export JAVA_HOME_8=$(/usr/libexec/java_home -v1.8)
export JAVA_HOME_9=$(/usr/libexec/java_home -v9)
And add the following aliases:
alias java7='export JAVA_HOME=$JAVA_HOME_7′
alias java8='export JAVA_HOME=$JAVA_HOME_8′
alias java9='export JAVA_HOME=$JAVA_HOME_9′
And can switch to required version by using the alias:
In terminal:
~ >> java7
export JAVA_HOME=$JAVA_7_HOME
Solution no. 6:
Another alternative is using SDKMAN! See https://wimdeblauwe.wordpress.com/2018/09/26/switching-between-jdk-8-and-11-using-sdkman/
First install SDKMAN: https://sdkman.io/install and then…
- Install Oracle JDK 8 with:
sdk install java 8.0.181-oracle
- Install OpenJDK 11 with:
sdk install java 11.0.0-open
To switch:
- Switch to JDK 8 with
sdk use java 8.0.181-oracle
- Switch to JDK 11 with
sdk use java 11.0.0-open
To set a default:
- Default to JDK 8 with
sdk default java 8.0.181-oracle
- Default to JDK 11 with
sdk default java 11.0.0-open
Solution no. 7:
You can use asdf to install and switch between multiple java versions. It has plugins for other languages as well. You can install asdf with Homebrew
When asdf is configured, install java plugin
Pick a version to install
For example to install and configure adoptopenjdk8
And finally if needed, configure JAVA_HOME for your shell. Just add to your shell init script such as ~/.zshrc in case of zsh:
Solution no. 8:
IMHO, There is no need to install all the additional applications/packages.
Check available versions using the command:
Now if you want to pick Azul JDK 8 in the above list, and NOT Oracle's Java SE 8, invoke the command as below:
To pick Oracle's Java SE 8 you would invoke the command:
As you can see the version number provided shall be the unique set of strings: 1.8.0_181 vs 1.8.0_151
Solution no. 9:
This answer extends on Jayson's excellent answer with some more opinionated guidance on the best approach for your use case:
- SDKMAN is the best solution for most users. It's easy to use, doesn't have any weird configuration, and makes managing multiple versions for lots of other Java ecosystem projects easy as well.
- Downloading Java versions via Homebrew and switching versions via jenv is a good option, but requires more work. For example, the Homebrew commands in this highly upvoted answer don't work anymore. jenv is slightly harder to setup, the plugins aren't well documented, and the README says the project is looking for a new maintainer. jenv is still a great project, solves the job, and the community should be thankful for the wonderful contribution. SDKMAN is just the better option cause it's so great.
- Jabba is written is a multi-platform solution that provides the same interface on Mac, Windows, and PC (it's written in Go and that's what allows it to be multiplatform). If you care about a multiplatform solution, this is a huge selling point. If you only care about running multiple versions on your Mac, then you don't need a multiplatform solution. SDKMAN's support for tens of popular SDKs is what you're missing out on if you go with Jabba.
Managing versions manually is probably the worst option. If you decide to manually switch versions, you can use this Bash code instead of Jayson's verbose code (code snippet from the homebrew-openjdk README:
Jayson's answer provides the basic commands for SDKMAN and jenv. Here's more info on SDKMAN and more info on jenv if you'd like more background on these tools.
Solution no. 10:
To stay with a specific major release, activate the AdoptOpenJDK tap with brew tap and then install the desired version with brew cask install:
Java Version 8 Update 77
To install AdoptOpenJDK 14 with HotSpot, run:
Hope this helps!
See JDK 7 and JRE 7 Installation Guide for general information about installing JDK 7 and JRE 7.
See the Mac OS X Platform Install FAQ for general information about installing JRE 7 on Mac OS X.
Contents
System Requirements
- Any Intel-based Mac running Mac OS X 10.7.3 (Lion) or later.
- Administrator privileges.
Note that installing the JRE on a Mac is performed on a system wide basis, for all users, and administrator privileges are required. You cannot install Java for a single user.
Only one JRE can be installed at a time. The system will not install a JRE that has a lower version than the current version. If you wish to install a lower version of the JRE, first uninstall the current version. Installing a JRE from Oracle will not update java -version symlinks or add java to your path. To be able to do this, you need to install the JDK.JRE 7 Installation Instructions
The JRE installation includes the JavaFX Runtime which is incorporated into the same directory structure.
Installation of the 64-bit JRE on Mac Platforms
Depending on your processor, the downloaded file has one of the following names:
- jre-7u-macosx-amd64.dmg
- jre-7u-macosx-x64.dmg
Where is 6 or later.
1. Download the file. Before the file can be downloaded, you must accept the license agreement.
2. From either the Downloads window of the browser, or from the file browser, double click the .dmg file to launch it.
3. A Finder window appears containing an icon of an open box and the name of the .pkg file Double click the package icon to launch the Install app.
4. The Install app displays the Introduction window. Click Continue.
4a. Note that, in some cases, a Destination Select window appears. This is a bug, as there is only one option available. If you see this window, select Install for all users of this computer to enable the continue button. Click Continue.
5. The Installation Type window appears. Click Install.
6. A window appears which says 'Installer is trying to install new software. Type your password to allow this.' Enter the Administrator login and password and click Install Software.
7. The software is installed and a confirmation window appears.
After the software is installed, delete the dmg file if you want to save disk space.
Determining the Installed Version of the JRE
If you have not yet installed Apple's Java Mac OS X 2012-006 update, then you are still using a version of Apple Java 6 that includes the plug-in and the Java Preferences app. See Note for Users of Macs that Include Apple Java 6 Plug-in.Only one JRE can be installed. Installing a JRE removes the previously installed JRE. The JRE version used by the system can be determined in one of two ways:
- From System Preferences click the Java icon from the Other category. This launches the Java Control Panel. Click About...
- Type the following in a Terminal window:
The system will not install a JRE that has a lower version than the current version. If you want to install a lower version, first uninstall the existing version.
Uninstalling the JRE
To uninstall the JRE, you must have Administrator privileges and execute the remove commands either as root or by using the sudo(8) tool.
Remove one directory and one file (a symlink), as follows:
- Navigate to /Library/Internet Plug-Ins and remove the JavaAppletPlugin.plugin directory.
- Navigate to /Library/PreferencePanes and remove JavaControlPanel.prefpane.
Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.