How to downgrade Java from 9 to 8 on a macOS Sierra 10.12.6(16G29) . I tried removing the Java plugin and installed Java 8, however the Java and javac version shows 9 in terminal, but In system preferences it is 8.
-
1The version of MacOS may be relevant; consider editing & adding that to the question (not posting as a comment). – AJNeufeld Oct 01 '17 at 15:07
-
did you have a look at https://wiki.eclipse.org/Configure_Eclipse_for_Java_9? – cello Oct 01 '17 at 16:20
9 Answers
You don't need to down grade. You can run more than one version of Java on MacOS. You can set the version of your terminal with this command in MacOS.
# List Java versions installed
/usr/libexec/java_home -V
# Java 11
export JAVA_HOME=$(/usr/libexec/java_home -v 11)
# Java 1.8
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
# Java 1.7
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
# Java 1.6
export JAVA_HOME=$(/usr/libexec/java_home -v 1.6)
You can set the default value in the .bashrc, .profile, or .zprofile

- 4,279
- 1
- 7
- 7
-
5Thanks a lot, that helped me! It's a shame that Java Control Panel in MacOS doesn't expose settings like this. – sesm Nov 10 '17 at 17:10
-
2Could you please elaborate your answer? What does `/usr/libexec/java_home -v 11` mean? – Sandeepan Nath Jun 01 '19 at 09:47
-
2Doing `export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)` and `export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_211)` doesn't solve my problem. Already restarted my terminal also. – HendraWD Jul 03 '19 at 06:54
-
I keep getting "JAVA_HOME: inconsistent type for assignment". And the java version doesn't change. Any clue how to fix this? – Daniel Reina Nov 22 '21 at 18:51
-
Thanks this helping me to run SonarQube on my Mac. Because SonarQube doesn't support Java 11+ – Nagaraj Alagusundaram Aug 24 '22 at 06:10
This is how I did it. You don't need to delete Java 9 or newer version.
Step 1: Install Java 8
You can download Java 8 from here: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Step 2: After installation of Java 8. Confirm installation of all versions.Type the following command in your terminal.
/usr/libexec/java_home -V
Step 3: Edit .bash_profile
sudo nano ~/.bash_profile
Step 4: Add 1.8 as default. (Add below line to bash_profile file).
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
Now Press CTRL+X to exit the bash. Press 'Y' to save changes.
Step 5: Reload bash_profile
source ~/.bash_profile
Step 6: Confirm current version of Java
java -version

- 5,768
- 3
- 44
- 47
-
Is it possible to change javaws version in same way? Because java -version reports that it changed, but javaws still runs newest available. – lapkritinis Jan 04 '19 at 14:18
If you have multiple Java versions installed on your Mac, here's a quick way to switch the default version using Terminal. In this example, I am going to switch Java 10 to Java 8.
$ java -version
java version "10.0.1" 2018-04-17
Java(TM) SE Runtime Environment 18.3 (build 10.0.1+10)
Java HotSpot(TM) 64-Bit Server VM 18.3 (build 10.0.1+10, mixed mode)
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
10.0.1, x86_64: "Java SE 10.0.1" /Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
1.8.0_171, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk-10.0.1.jdk/Contents/Home
Then, in your .bash_profile add the following.
# Java 8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
Now if you try java -version again, you should see the version you want.
$ java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)

- 549
- 6
- 15
As it allows to install more than one version of java, I had install many 3 versions unknowingly but it was point to latest version "11.0.2"
I could able to solve this issue with below steps to move to "1.8"
$java -version
openjdk version "11.0.2" 2019-01-15 OpenJDK Runtime Environment 18.9 (build 11.0.2+9) OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
cd /Library/Java/JavaVirtualMachines
ls
jdk1.8.0_201.jdk jdk1.8.0_202.jdk openjdk-11.0.2.jdk
sudo rm -rf openjdk-11.0.2.jdk
sudo rm -rf jdk1.8.0_201.jdk
ls
jdk1.8.0_202.jdk
java -version
java version "1.8.0_202-ea" Java(TM) SE Runtime Environment (build 1.8.0_202-ea-b03) Java HotSpot(TM) 64-Bit Server VM (build 25.202-b03, mixed mode)

- 2,965
- 3
- 25
- 30
-
1I'd avoid removing files on your system. Instead just redirect the `$JAVA_HOME` env variable. – simeg Mar 08 '19 at 12:44
Old question but just had that problem /dumb jira having problems with java 10/ and didn't find a simple answer here so just gonna leave it:
$ /usr/libexec/java_home -V
shows the versions installed and their locations so you can simply remove /Library/Java/JavaVirtualMachines/<the_version_you_want_to_remove>
. Voila

- 619
- 1
- 8
- 18
As mentioned in the offical Oracle Documentation there are two relevant paths you need to delete in case you wan't to remove a Java installation.
Path 1 is the JRE - installation path: /Library/Internet Plug-Ins/
Path 2 is the JDK - installation path: /Library/Java/JavaVirtualMachines
JRE Steps:
Change directory via Terminal to the Path 1.
cd /Library/Internet Plug-Ins/
Remove JavaAppletPlugin.plugin
sudo rm -rf JavaAppletPlugin.plugin
JDK Steps:
Do the Steps under JRE Steps
Change directory via Terminal to the Path 2.
/Library/Java/JavaVirtualMachines
Take a look at all installations at this folder
ls
Remove any installations in this folder.
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-(...).jdk
After uninstalling you are ready to go for a fresh installation. Just download you're version of choice and install it.

- 33
- 8
The simplest solution might be to install Java 8 in parallel to Java 9 (if not still still existant) and specify the JVM to be used explicitly in eclipse.ini
. You can find a description of this setting including a description how to find eclipse.ini
on a Mac at Eclipsepedia

- 5,323
- 1
- 11
- 27
FOR MAC USERS only
Change for both JRE and JDK version
Path 1 is the JRE - installation path: /Library/Internet Plug-Ins/ Path 2 is the JDK - installation path: /Library/Java/JavaVirtualMachines
JRE Steps: Change directory via Terminal to the Path 1.
cd /Library/Internet Plug-Ins/ Remove JavaAppletPlugin.plugin
sudo rm -rf JavaAppletPlugin.plugin JDK Steps: Do the Steps under JRE Steps Change directory via Terminal to the Path 2.
step 1
/Library/Java/JavaVirtualMachines
Take a look at all installations at this folder
step 2
ls // to list all files in folder
Remove any installations in this folder.
step 3
sudo rm -rf /Library/Java/JavaVirtualMachines/yourjdkName.jdk
After uninstalling you are ready to go for a fresh installation. Just download you're version of choice and install it.
best solution for this

- 19
- 1
-
This worked for me thank you. I couldn't get the method of editing .bash_profile to work. – James Jul 13 '23 at 20:53
You can remove "JavaAppletPlugin.plugin" found in Spotlight or Finder, then re-install downloaded Java 8.
This will simply solve your problem.

- 1