Java on Linux doesn't need to be installed as root. You can install as many different Java versions you want on Linux, either in separate user accounts or in a single account.
I do it all the time (switching from one Java version to another) to test on various versions of the JVM.
Changing your Java version can be as simple as this:
Copy... $ which java
/home/b/jdk1.5.0_22/bin/java
... $ export PATH=/home/b/jdk1.6.0_25/bin:$PATH
... $ which java
/home/b/jdk1.6.0_25/bin/java
To fetch an old version, go to the "Oracle Java Archive" page (Google if link becomes broken):
http://www.oracle.com/technetwork/java/archive-139210.html
Then pick your poison. I download the .bin, chmod +x it and then I extract the Java version I want from the .tgz.
Then I simply set the PATH and I'm usually good to go.
I run my IDE (IntelliJ IDEA) using one Java version, I typically compile using another JDK and I test on several JVMs.
All this from the same user account.
So it's not as if you had to install "one" Java version on a Linux system...
Now, concretely, if I were you, I'd simply remove all traces from Java while being root, and then I'd download the old version I need from the Oracle Java Archive.
Answer from TacticalCoder on Stack OverflowJava on Linux doesn't need to be installed as root. You can install as many different Java versions you want on Linux, either in separate user accounts or in a single account.
I do it all the time (switching from one Java version to another) to test on various versions of the JVM.
Changing your Java version can be as simple as this:
Copy... $ which java
/home/b/jdk1.5.0_22/bin/java
... $ export PATH=/home/b/jdk1.6.0_25/bin:$PATH
... $ which java
/home/b/jdk1.6.0_25/bin/java
To fetch an old version, go to the "Oracle Java Archive" page (Google if link becomes broken):
http://www.oracle.com/technetwork/java/archive-139210.html
Then pick your poison. I download the .bin, chmod +x it and then I extract the Java version I want from the .tgz.
Then I simply set the PATH and I'm usually good to go.
I run my IDE (IntelliJ IDEA) using one Java version, I typically compile using another JDK and I test on several JVMs.
All this from the same user account.
So it's not as if you had to install "one" Java version on a Linux system...
Now, concretely, if I were you, I'd simply remove all traces from Java while being root, and then I'd download the old version I need from the Oracle Java Archive.
like tactical coder said, you can install as many versions as you want, to switch the current version just run:
Copysudo update-alternatives --config java
And select the desired version.
If you wish, run it for javac and javaws:
Copysudo update-alternatives --config javac
sudo update-alternatives --config javaws
Source: https://askubuntu.com/questions/56104/how-can-i-install-sun-oracles-proprietary-java-jdk-6-7-8-or-jre
How do I downgrade JDK?
centos - How to yum downgrade to a specific version of packet like jdk? - Unix & Linux Stack Exchange
How to downgrade from java11 to java8?
java - How to downgrade JDK? - Stack Overflow
Videos
I installed JDK with the Ubuntu Software application which selected JDK-16.0.2, and I need to downgrade to version 11.
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?
Create new custom variable that point to the preferred version

Set %JAVA_HOME%/bin as first entry to Path Variable

Profit!
Check with
java -version
Why not just remove the Oracle Java path entry and not worry about your JAVA_HOME placement in the Path?
You might suggest to simply remove the Oracle Java path that was prepended to your Windows PATH by the installer. Yes, I thought of that too, but the installer also copies the java.exe, javaw.exe, and javaws.exe files to C:\Windows\System32 directory, which is also in the Windows PATH variable. So rather than chase down all the possible directories that the installer put Java, and to avoid deleting the System32 files that actually may be necessary to some process somewhere, I decided that simply prepending my preferred Java Home directory to the path was best option.
Source: How to set custom Java path after installing JDK 8 โ Douglas C. Ayers
For linux users run command sudo update-alternatives --config java
it will return the list of java JDKs you have and you can simply use its index to select your preferred version
First, there is no need to "downgrade"; multiple simultaneous versions are supported. You can install Java 6, something like
sudo apt-get install openjdk-6-jdk
Then you can do something like (depending on platform)
export INSTALL4J_JAVA_HOME="/usr/lib/jvm/java-6-openjdk-amd64"
If you find what command you used, you might be able to get other help, like if the command was broken, or may need other packages.
You probably just need to install openjdk-6-jre like Elliot said, but just in case, you might as well.
I downloaded new fabric mod loader in minecraft and it seems to be that i have problem with my Java version, I was using JDK 21 instead of JDK25.
So i updated by downloading open jdk 25 from Oracle.
i installed .deb file
and when i typed " java --version " in terminal it was still showing that i'm using Java 21
then to change version i used command
sudo update-alternatives --config java
and
sudo update-alternatives --config javac
and selected JDK-25
i closed terminal, opened again and did " java --version" and still it's stuck at Java 21.
am I doing something wrong ?
can someone please help me.


