Tech Junkie Blog - Real World Tutorials, Happy Coding!: Fedora: Install Oracle JDK

Friday, August 10, 2018

Fedora: Install Oracle JDK

Linux installation comes with OpenJDK, but you want to use the official JDK from Oracle instead to run most of the software.  This post will show you the steps to install the Oracle JDK

First let's check to see what version of JDK we have installed by running the command

java -version











As you can see Fedora installs the OpenJDK library by default.  What we want to do is replace it with the Oracle version instead.

Type the address http://www.oracle.com/technetwork/java/javase/downloads/index.html
into Firefox in the Fedora VM and click on the "JDK" download button




































Accept the license agreement and download the Linux version

































Select "Save File" then click "OK"



















Once the file is downloaded you can find the file at your home directory by typing

cd ./Downloads/











Now we want to create a folder call java in the path /usr/local with this command

sudo mkdir -p /usr/local/java















Since this is going to be our development machine we can just switch to the super user with the command sudo su to speed things up










Now copy the files to the local/java folder with this command

cp -r jdk-10.0.2_linux-x64._bin.tar.gz /usr/local/java

Navigate to the /usr/local/java folder with the command cd /usr/local.java and extract the .tar file with this command

tar xvzf jdk-10.0.2_linux-x64._bin.tar.gz

Open the /etc/profile file with the command nano /etc/profile and add the following line to the end of the file

JAVA_HOME=/usr/local/java/jdk-10.0.2
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

Press Ctrl+O to save the file, then Press Ctrl+X to exit
Type the following commands in the terminal

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jdk-10.0.2/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk-10.0.2/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jdk-10.0.2/bin/javaws" 1

Type in the following commands to make Oracle JDK the default JDK

sudo update-alternatives --set java /usr/local/java/jdk-10.0.2/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk-10.0.2/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jdk-10.0.2/bin/javaws

Type the following command to apply the configuration in the /etc/profile file











Reboot Fedora by typing reboot

You have successfully installed the Oracle JDK on Fedora.


Similar Posts:

2 comments:

  1. Transform your event into an unforgettable experience by choosing to make your event magical with a strolling magician. These enchanting performers move through the crowd, captivating guests with close-up magic that amazes and delights. Their interactive tricks create personal moments of wonder, making everyone feel like part of the magic. Whether it's a corporate event, wedding, or party, a strolling magician adds an element of surprise and excitement. Make your event magical with a strolling magician and watch as your guests are spellbound, ensuring your event is remembered for years to come.

    ReplyDelete

Search This Blog