📢 This article was translated by gemini-2.5-flash
Intro
Fedora comes with Java, but it’s OpenJDK. Sometimes, you just need Oracle’s version.
Download
Head to the official site to download:
Java Downloads | Oracle
(Requires login to download)
Find java8-Linux, then grab the x64 Compressed Archive (that’s the 64-bit compressed package).
As of writing, the file was named jdk-8u341-linux-x64.tar.gz.
Move to Directory
- First, create a Java directory under /usr/local.
1
| sudo mkdir -p /usr/local/java
|
- Copy the file there.
Assuming your download is in ~/Downloads, navigate to it.
Then copy it to the directory we just made.
1
| sudo cp -r jdk-8u341-linux-x64.tar.gz /usr/local/java
|
- Switch to the Java directory.
- Extract the installation file.
1
| sudo tar xvzf jdk-8u341-linux-x64.tar.gz
|
- Add these lines to the end of /etc/profile.
1
2
3
4
| JAVA_HOME=/usr/local/java/jdk1.8.0_341
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH
|
Update Available Java Versions
- Run these commands directly.
1
| sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk1.8.0_341/bin/java" 1
|
1
| sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk1.8.0_341/bin/javac" 1
|
1
| sudo update-alternatives --install "/usr/bin/javaws.itweb" "javaws.itweb" "/usr/local/java/jdk1.8.0_341/bin/javaws.itweb" 1
|
Apply Configuration
- First, reload the system-wide PATH file.
- Reboot your system.
Switch Java Version
You can check the current Java version by running:
- Use the following command to switch:
1
| sudo alternatives --config java
|
The currently active Java version will have a + next to it. Find your desired version and type its number to select.
References
How to Install Java on Fedora {OpenJDK and Oracle JDK}