How To Install Java JDK and JRE on Oracle Linux Server 9

How To Install Java JDK and JRE on Oracle Linux Server 9

 Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.
OpenJDK or Oracle Java
OpenJDK is an open-source implementation of the Oracle Java SE platform edition. Oracle develops Oracle Java SE, whereas the OpenJDK is developed by Oracle Corporation, OpenJDK and Java Community, Red Hat, Azul Systems, IBM, Apple Inc, and SAP SE.
__________________________________________________________________________________________________________________________________
Server - Os:  Oracle Linux Server 9   64Bit      | IP -192.168.1.50        |Hostname - server.testbox.com
__________________________________________________________________________________________________________________________________
cat /etc/system-release ; dnf groupinstall "Development Tools" -y

Method - 1
dnf update
sudo dnf install java-11-openjdk java-11-openjdk-devel
java -version


Method - 2
Install Java OpenJDK 16 Manually from TAR.GZ File-
wget https://download.java.net/java/GA/jdk16.0.2/d4a915d82b4c4fbb9bde534da945d746/7/GPL/openjdk-16.0.2_linux-x64_bin.tar.gz
tar -xf openjdk-16.0.2_linux-x64_bin.tar.gz
mkdir -p /usr/lib/jvm ; mv jdk-16.0.2 /usr/lib/jvm

alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-16.0.2/bin/java" 0
alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk-16.0.2/bin/javac" 0
alternatives --list
sudo alternatives --config java
sudo alternatives --config javac
java --version ; javac --version

Setup JAVA_HOME Environment Variable-
cd /etc/profile.d/ ; nano java.sh

JAVA_HOME="/usr/lib/jvm/jdk-16.0.2"
source /etc/profile.d/java.sh
echo $JAVA_HOME
__________________________________________________________________________________________________________________________________

Test Java Installation-
nano HelloWorld.java
public class helloworld {
  public static void main(String[] args) {
    System.out.println("Hello Java World from india!");
  }
}
java HelloWorld.java




Share on Pinterest
Share on LinkedIn
Share on WhatsApp
Share on Telegram