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 › @thxall92 › mac-downgrade-java-11-java-8-41c2f8eca32c
[Mac] Downgrade Java 11 -> Java 8 | by Thxall92 | Medium
May 24, 2019 - Step 1: Install Java 8 http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html Matching Java Virtual Machines (2): 11.0.2, x86_64: “Java SE 11.0.2”…
Discussions

How to downgrade from java11 to java8?
Try running these commands: wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | apt-key add - add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/ apt-get update -y && apt-get install -y adoptopenjdk-8-hotspot More on reddit.com
🌐 r/Crostini
10
6
October 24, 2020
macos - How to downgrade JRE/JDK on Mac OSX? - Stack Overflow
Does anyone know how to downgrade the version for JRE/JDK from 1.6.0_24 to 1.6.0_18 on a Mac OSX thru Terminal? I need to downgrade in order to get a Java applet working in Firefox. Any help would be More on stackoverflow.com
🌐 stackoverflow.com
macos - How to downgrade the java version in mac - Stack Overflow
My current java version details:- I followed the steps which are mentioned in the official java web site. Below are related steps screenshot:- After executing these commands, the java version remai... More on stackoverflow.com
🌐 stackoverflow.com
June 7, 2018
How can I downgrade my Java version and R… - Apple Community
Sorry if I'm stupid and that actually does downgrade everything. (it didn't when I did it) ... How can I uninstall Oracle Java 7 and reinstall Apple's Java 6 on my Mac? - Knowledgebase - ParaChat · If you have no happiness from these, then try a Google search which is how I found the above. ... Minionsman, check this out: http://wisebyte.blogspot.com/2012/11... More on discussions.apple.com
🌐 discussions.apple.com
🌐
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 ·
🌐
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 ...
🌐
Reddit
reddit.com › r/crostini › how to downgrade from java11 to java8?
r/Crostini on Reddit: How to downgrade from java11 to java8?
October 24, 2020 -

I have spent around 2 weeks now scouring all over the web trying to find out how to install it without it giving some stupid error like "E: Unable to locate package openjdk-8-jdk" and it not getting detected by the system. I have manged to install open-java8 on sdk, but the system does not detect it. I need java8 for minecraft as older modded versions of the game are really buggy in java11 and crash at start. How can I install and downgrade to java8, and for an linux application for minecraft, be able to see it?

🌐
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
This post includes Java LTS version 17 and shows how to switch between Java/JDK LTS versions 8, 11 and 17. ~ 2 minutes read no time? jump straight to the javahome function · On Mac you can install Java/JVM with brew‘s openjdk formulae .
🌐
University of Oregon
service.uoregon.edu › TDClient › KB › ArticleDet
Reverting to a Previous Version of Java (macOS)
January 31, 2018 - This page explains how to uninstall your current version of Java and then install an older version. These instructions focus on Java 8.
Find elsewhere
🌐
Super User
superuser.com › questions › 1386991 › downgrade-to-java-8-from-java-10-on-mac-so-that-netbeans-can-work
macos - Downgrade to Java 8 from Java 10 on Mac so that Netbeans can work - Super User
December 22, 2018 - Replace whatever the value is for that property with the path to your JDK 8 installation. For example, on my Windows 10 machine that line looks like this for my NetBeans 8.2 installation: netbeans_jdkhome="C:\Java\jdk1.8.0_181"
🌐
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.
🌐
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 - export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_222` ... # 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
🌐
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.
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.
🌐
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.
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
Top answer
1 of 4
3

If anyone still cares about downgrading Java on Snow Leopard, the answer that advises removing Java manually and reinstalling from download or Snow Leopard DVD doesn't work for Snow Leopard, but it can be made to work.

Instead of using the freestanding Java packages on the DVD, use the app Pacifist to open the main Snow Leopard installer .pkg. Then search for "java" and install every item that matches (you can skip the JavaScript items, obviously). This fixes the error reported in the linked article (which is offline but available at archive.org):

"Error occurred during initialization of VM Unable to load native library: libjava.jnilib"

Apparently there are additional pieces to a functioning Java install not included in the separate .pkg files.

2 of 4
2

This article has a pretty good answer as long as you still have your boot disk or can find a downloadable version of Java you need. Here are the instructions (copied and pasted from the article):

1 Recommend making a bootable backup before starting

2 Locate the required Java installers

 - Leopard: download update 5
 - Snow Leopard: grab your install DVD

3 Remove current installed java stuff (warning: no going back from this point on!). In terminal:

 sudo rm -R /Applications/Utilities/Java\ Preferences.app/
 sudo rm -R /System/Library/Frameworks/JavaVM.framework/
 sudo rm -R /System/Library/Java/
 sudo rm -R /System/Library/CoreServices/Jar\ Launcher.app
 sudo rm -R /System/Library/CoreServices/Java\ Web\ Start.app/
 sudo rm -R /System/Library/CoreServices/JavaVersion.plist
 sudo rm -R /System/Library/PrivateFrameworks/JavaApplicationLauncher.framework/
 sudo rm -R /System/Library/Frameworks/JavaEmbedding.framework/
 sudo rm -R /System/Library/CFMSupport/StubLibraries/JavaEmbeddingLib/

4.1 Reinstall java: Leopard

 - run the installer that you downloaded in step 1
 - restart

4.2 Reinstall java: Snow Leopard (haven't tested yet! but should work)

 - insert installer DVD
 - run terminal commands (change the paths in each command as necessary for both the OS X Install disc and your system hard drive):
      installer -verbose -pkg "/Volumes/Mac OS X Install Disk/System/Installation/Packages/Java.pkg -target /Volumes/Macintosh HD"
      installer -verbose -pkg "/Volumes/Mac OS X Install Disk/System/Installation/Packages/JavaTools.pkg -target /Volumes/Macintosh HD"
 - (alternately you can use a tool like Pacifist to browse for and run the Java.pkg and JavaTools.pkg installers located in the main .pkg installer)
 - restart

Note: we have confirmed this works for Leopard but haven't verified for Snow Leopard yet.

🌐
GitHub
gist.github.com › gwpantazes › 50810d5635fc2e053ad117b39b597a14
How to install different JDK versions on MacOS with Homebrew · GitHub
We can see some of the formulae/casks we're looking for, such as java, java11, or java-beta. $ brew search jdk ==> Formulae openjdk ✔ openjdk@11 ✔ openjdk@8 ✔ ==> Casks adoptopenjdk jdk-mission-control oracle-jdk-javadoc adoptopenjdk8 oracle-jdk sapmachine-jdk