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 OverflowYou 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
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
How to downgrade from java11 to java8?
macos - How to downgrade JRE/JDK on Mac OSX? - Stack Overflow
How can I downgrade my Java version and R… - Apple Community
macos - How to downgrade the java version in mac - Stack Overflow
Videos
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?
That does not seem to be accurate any more.
I just managed to downgrade both JRE and compiler from Java 8 to 7 by looking into /Library/Java/JavaVirtualMachines, and moving away the directory with the highest version number, e.g.
sudo mv jdk1.8.0.jdk ~/Desktop/
That's easy. You have to remove de .jdk directory of the JDK 7 in /Library/Java/JavaVirtualMachines. Now you only have to install the version you like. =)
More info: http://docs.oracle.com/javase/7/docs/webnotes/install/mac/mac-jdk.html#uninstall
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.
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
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.
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.