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

Answer from mdeterman on Stack Overflow
🌐
Medium
medium.com › miro-engineering › how-to-switch-between-java-lts-versions-8-11-and-17-on-mac-cb6717d1272
How to switch between Java LTS versions 8, 11, and 17 on Mac | by Lothar Schulz | Miro Engineering | Medium
November 25, 2021 - Now you can change the java version on the terminal using the respective alias: $ j17 openjdk version "17.0.1" 2021-10-19 OpenJDK Runtime Environment Homebrew (build 17.0.1+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.1+0, mixed mode, sharing)$ j11 openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment Homebrew (build 11.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)$ j1.8 openjdk version "1.8.0_312" OpenJDK Runtime Environment (build 1.8.0_312-bre_2021_10_20_23_15-b00) OpenJDK 64-Bit Server VM (build 25.312-b00, mixed mode)
🌐
Medium
medium.com › reachnow-tech › change-default-java-version-on-mac-a7f01647f126
Change default Java version on Mac | by Lothar Schulz | reachnow-tech | Medium
September 6, 2019 - How to change default java version on Mac from Java version 11.0.2 to Java version 1.8 to enable a service transition.
🌐
Quora
quora.com › How-do-I-downgrade-Java-on-Mac
How to downgrade Java on Mac - Quora
Answer: You can install multiple versions of the JDK simultaneously. Look in /Library/Java/JavaVirtualMachines/ to see which versions are currently installed. There is a folder named CurrentJDK, which is actually a symbolic link to one of the other folders. Remove it and create a new symbolic ...
🌐
Lotharschulz
lotharschulz.info › 2021 › 11 › 30 › how-to-switch-between-java-lts-versions-8-11-and-17-on-mac
How to switch between Java LTS versions 8, 11 and 17 on Mac – Lothar Schulz
javahome() { unset JAVA_HOME export JAVA_HOME=$(/usr/libexec/java_home -v "$1"); java -version }alias j1.8='javahome 1.8' alias j11='javahome 11' alias j17='javahome 17'j17 #this makes version 17 the default version until you change it · This will set java version 17 when ever your .zshrc file (or similar) is executed. ... On my Mac (mojave 10.14.6) installing java 11 failed with a compilation error “src/jdk.hotspot.agent/macosx/native/libsaproc/symtab.c:407:71: error: too few arguments to function call, expected 5, have 4”.
🌐
Oracle
java.com › mac_uninstall_faq
How do I uninstall Java on my Mac?
Platform(s): macOS · Java version(s): 8.0 · Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo tool. Remove one directory and one file (a symlink), as follows: Click on the Finder icon located in your dock ·
🌐
University of Oregon
service.uoregon.edu › TDClient › 2030 › Portal › KB › ArticleDet
Reverting to a Previous Version of Java (macOS)
This page explains how to uninstall your current version of Java and then install an older version. These instructions focus on Java 8.
🌐
DEV Community
dev.to › rithvik78 › change-the-default-java-version-on-macos-3jee
Change the default Java Version on macOS - DEV Community
February 19, 2022 - Here, We are trying to change the version to Java SE 8 First run /usr/libexec/java_home -V which... Tagged with macos, java, jdk, javase8.
Find elsewhere
🌐
Lotharschulz
lotharschulz.info › 2019 › 08 › 21 › mac-change-default-java-version
Change Java version on Mac – Lothar Schulz
August 21, 2019 - $ brew cask install adoptopenjdk/openjdk/adoptopenjdk8 # which java versions installed $ /usr/libexec/java_home -V Matching Java Virtual Machines (2): 11.0.2, x86_64: "OpenJDK 11.0.2" /Library/.../openjdk-11.0.2.jdk/Contents/Home 1.8.0_222, x86_64:"AdoptOpenJDK 8" /Library/.../adoptopenjdk-8.jdk/Contents/Home # set the new default version export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_222` ... Downgrade worked fine for my Mac Catalina.
Top answer
1 of 1
5

Install another JDK

You can install multiple JDKs on your Mac. You can have a JDK for Java 11 as well as a JDK for Java 17. And perhaps you might want another JDK for the new Java 21 that arrived yesterday. These can all live together, side-by-side.

Each JDK is just a folder full of files. You can add JDKs, and delete JDKs, at will.

The environment variable JAVA_HOME is a hint various software as to which JDK you would like to use by default.

You might find a feature within Android Studio to install another JDK. (At least the sibling product, IntelliJ, offers such a feature.)

Configure project

Within your project in Android Studio, you need to set some settings to indicate which of your installed JDKs should be used for compiling, building, and executing your app. See the Android Studio documentation.

SDKMAN!

Personally, I find it easiest to install SDKMAN!, a bunch of shell scripts that manage installing/uninstalling JDKs (and other such kits). This works well on macOS.

SDKMAN! is designed to be utterly simple to use.

On a console such as Terminal.app, execute:

  • sdk list java
    See a list of all JDK products from vendors who chose to submit their data to the SDKMAN! database. From this list you copy the exact name of the JDK product you want to install. The list of products indicates any you have currently installed.
  • sdk install java product_name_goes_here
    Install the JDK product of your choosing. Takes a moment to download and install. At the end, SDKMAN! prompts you to specify whether you want to make this newly installed JDK the default.
  • sdk uninstall java product_name_goes_here
    Removes that particular JDK product from your Mac.
🌐
Medium
medium.com › @haroldfinch01 › step-by-step-guide-installing-and-switching-java-versions-on-mac-osx-f3896b9872f4
Step-by-Step Guide: Installing and Switching Java Versions on Mac OSX | by Harold Finch | Medium
May 21, 2024 - Step-by-Step Guide: Installing and Switching Java Versions on Mac OSX To install Java on macOS and allow for easy switching between different versions, you can use a version manager like jenv. Here's …
Top answer
1 of 9
2

Here is how I do it on my Linux (Ubuntu / Mint mate), I guess Mac can do it similarly.


Install & config

Steps:

  • [Basic - part]
  • Download jdk (the .tgz file) by hand.
  • Uncompress & rename properly, at a proper location.
    e.g /mnt/star/program/java/jdk-1.8
  • Make a soft link, which will be changed to switch java version later.
    e.g ln -s /mnt/star/program/java/jdk-1.8 /mnt/star/program/java/java
    Thus /mnt/star/program/java/java is the soft link.
  • Set JAVA_HOME in a start script.
    Could use file like /etc/profile.d/eric.sh, or just use ~/.bashrc.
    e.g JAVA_HOME=/mnt/star/program/java/java
  • Then open a new bash shell. java -version should print the java version.
  • [More version - part]
  • Download & install more Java version, as need, similar as above steps.
    e.g
    /mnt/star/program/java/jdk-11
  • [Switch - part]
  • In ~/.bashrc, define variable for various Java version.
    e.g
    _E_JAVA_HOME_11='/mnt/star/program/java/jdk-11'
    _E_JAVA_HOME_8='/mnt/star/program/java/jdk-8'
    # dir of default version,
    _E_JAVA_HOME_D=$_E_JAVA_HOME_8
  • In ~/.bashrc, define command to switch Java version.
    e.g
    ## switch java version,
    alias jv11="rm $JAVA_HOME; ln -s $_E_JAVA_HOME_11 $JAVA_HOME"
    alias jv8="rm $JAVA_HOME; ln -s $_E_JAVA_HOME_8 $JAVA_HOME"
    # default java version,
    alias jvd="rm $JAVA_HOME; ln -s $_E_JAVA_HOME_D $JAVA_HOME"
    alias jv="java -version"
  • In terminal, source ~/.bashrc to make the changes take effect.
  • Then could switch using the defined commands.

Commands - from above config

Commands:

  • jv11
    Switch to Java 11
  • jv8
    Switch to Java 8
  • jvd
    Switch to default Java version, which is denoted by _E_JAVA_HOME_D defined above.
  • jv
    Show java version.

Example output:

eric@eric-pc:~$ jv
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

eric@eric-pc:~$ jv11
eric@eric-pc:~$ jv
java version "11.0.1" 2018-10-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.1+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

eric@eric-pc:~$ jvd
eric@eric-pc:~$ jv
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

eric@eric-pc:~$ 

Mechanism

  • It switch by changing the soft link, which is used as JAVA_HOME.

Tips

  • On my machine when install jdk by hand, I keep the minor version, then make a soft link with the major version but without the minor version.
    e.g
    // this is the actual dir,
    jdk1.8.0_191

    // this is a soft link to jdk1.8.0_191
    jdk-8

    // this is a soft link to jdk-8 or jdk-11
    java

  • I define command alias in ~/.bashrc, but define variable in a separate file.
    I am using ~/.eric_var to define the variables, and ~/.bashrc will source it (e.g source $HOME/.eric_var).

2 of 9
2

A very simple way to change the default Java version on MacOS via HomeBrew:

Start with:

brew install openjdk@17

Once it completes. Run:

sudo ln -sfn /opt/homebrew/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk

Enter your machine's password and finally run the 2 commands one after another.

export JAVA_HOME=$(/usr/libexec/java_home -v 17) // Specify your own version
export PATH=$JAVA_HOME/bin:$PATH

Check Java Version:

java -version

You're good to go:

openjdk version "17.0.14" 2025-01-21
OpenJDK Runtime Environment Homebrew (build 17.0.14+0)
OpenJDK 64-Bit Server VM Homebrew (build 17.0.14+0, mixed mode, sharing)
🌐
Apple Community
discussions.apple.com › thread › 4513733
How can I downgrade my Java version and R… - Apple Community
Go to /System/Library/Java/JavaVirtualMachines/ and delete anything whose name starts with jdk1.7.0 or says Java 7 or something similar. ... Hi. I am currently working on 10.8.4 OSX. I had accidentally installed jdk1.7, downloaded and installed it from oracle site, and now have to downgrade it.
🌐
GitHub
github.com › adoptium › adoptium-support › issues › 1009
Downgrading MacOS Arm doesn't work from jdk-17.0.10+7 to jdk-17.0.9+9 · Issue #1009 · adoptium/adoptium-support
January 26, 2024 - What are you trying to do? Trying to downgrade from jdk-17.0.10+7 to jdk-17.0.9+9 (On Mac Arm, installing JDK arm.) Verified on two different Laptops Expected behavior: Afterward installing 17.0.9, the following should inform me, that 17...
Author   adoptium
🌐
Oracle
java.com › de › download › help › mac_uninstall_java.html
Wie deinstalliere ich Java auf meinem Mac?
Plattform(en): macOS · Browser: Kein Wert · Java version(en): 8.0 · Hinweis: Zur Deinstallation von Java benötigen Sie Administratorberechtigungen. Außerdem müssen Sie den remove-Befehl als Root oder mit dem sudo-Tool ausführen. So entfernen Sie ein Verzeichnis und eine Datei (einen ...
🌐
Apple Community
discussions.apple.com › thread › 6273363
How do I downgrade Java 8 to Java 7 Mac 1… - Apple Community
May 27, 2014 - I was going to play a game that requires Java, but it claims my Java version is outdated, so I can either choose to 'update', 'block' or 'later'. At first I tried 'update' and download Java 7, which is the latest on the website. When I opened the pkg it says I already have Java 8 installed and quitted the installer, so I went back to my game and tried again.
Top answer
1 of 5
4

I had this same problem: I had Java 8 installed, but later installed 10. Then, I removed 10, and when I launched a jar from the terminal it would run in version 8, and when I checked the version with java -version in the terminal I would get back java version "1.8.0_181. However when I ran a .jar from the Finder, it would run in v.10, and also if I went to the Java preference pane the version was listed as version 10. This was undesirable: I was trying to remove v10 completely.

Then, I deleted JavaAppletPlugin with rm /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin and reinstalled Java SE JDK 8 from online, and lo! it works now. When I run .jar, they run in Java 8.

I realize you mentioned this in your first step, but I infer that you didn't do this step? If I'm wrong about that then you've got a different problem. But this solved mine.

2 of 5
49

I believe the problem is navigating to the correct directory... Once you are where you are supposed to be you can run the sudo commands to remove whichever versions of java you want to remove.

First, run the command in the terminal to determine which version of Java you are running,

java -version

then you can navigate to pesky version of java that you intend to delete by using the following command:

cd /Library/Java/JavaVirtualMachines

then once you see are in the JavaVirtualMachines path, type in ls to see what versions of Java you have installed,

ls

and finally when you know which version or versions of Java you want to uninstall:

sudo rm -rf jdk-10.0.1.jdk #or whichever version you want to delete
🌐
GitHub
gist.github.com › gwpantazes › 50810d5635fc2e053ad117b39b597a14
How to install different JDK versions on MacOS with Homebrew · GitHub
$ brew cask info adoptopenjdk8 adoptopenjdk8: 8,252:b09 https://adoptopenjdk.net/ Not installed From: https://github.com/caskroom/homebrew-versions/blob/master/Casks/adoptopenjdk8.rb ==> Name AdoptOpenJDK 8 ==> Artifacts OpenJDK8U-jdk_x64_mac_hotspot_8u252b09.pkg (Pkg) ... @fazlizekiqi Homebrew's java points to the most recent stable OpenJDK (not Oracle!), so it will probably update to Java 14 in September 2020.