In our guide today, we will discuss how to install Java 17 (OpenJDK 17) Fedora 35/34/33/32. Java 17 is now available for general use-view General availability release notes For new features.Production-ready binaries can also be downloaded from Oracle Applies to Java SE Development Kit 17.
JDK 17 is an open source reference implementation of the 17th edition of the Java SE platform. Chapter 388 In the process of the Java community. Install JDK | Your OpenJDK 17 Fedora 35/34/33/32 Follow the steps below.
For Ubuntu / Debian , please use: Install Oracle Java 17 (OpenJDK 17) on Debian
Option 1: Install OpenJDK 17 Fedora 35/34/33/32
access JDK 17 release page Download the latest archive.
sudo dnf -y install curl wget
wget https://download.java.net/java/GA/jdk17/0d483333a00540d886896bac774ff48b/35/GPL/openjdk-17_linux-x64_bin.tar.gz
Use the tar command to extract the downloaded OpenJDK 17 archive file.
tar xvf openjdk-17_linux-x64_bin.tar.gz
Move the generated folder to the /opt directory.
sudo mv jdk-17 /opt/
Configure the Java environment:
sudo tee /etc/profile.d/jdk.sh <<EOF
export JAVA_HOME=/opt/jdk-17
export PATH=$PATH:$JAVA_HOME/bin
EOF
Get your profile and check java
Order
source /etc/profile.d/jdk.sh
Confirm the Java version.
$ echo $JAVA_HOME
/opt/jdk-17
$ java -version
openjdk 17 2021-09-14
OpenJDK Runtime Environment (build 17+35-2724)
OpenJDK 64-Bit Server VM (build 17+35-2724, mixed mode, sharing)
Option 2: Install Java SE Development Kit 17 on Fedora35/34/33/32
If you choose to go Java SE Development Kit 17 , Download the RPM package of CentOS / RHEL / Fedora The system uses the following commands.
wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.rpm
Then use yum or rpm command to install the RPM package.
$
sudo rpm -Uvh jdk-17_linux-x64_bin.rpm
warning: jdk-17_linux-x64_bin.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:jdk-17-2000:17-ga ################################# [100%]
Confirm the installed Java version
$
java -version
java version "17" 2021-09-14 LTS
Java(TM) SE Runtime Environment (build 17+35-LTS-2724)
Java HotSpot(TM) 64-Bit Server VM (build 17+35-LTS-2724, mixed mode, sharing)
Configure the Java environment.
cat <<EOF | sudo tee /etc/profile.d/jdk.sh
export JAVA_HOME=/usr/java/default
export PATH=$PATH:$JAVA_HOME/bin
EOF
To use Java Home, source files.
source /etc/profile.d/jdk.sh
Test the Java 17 installation on Fedora35/34/33/32
Create a HelloWorld Java program.
$
vi HelloWorld.java
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
Compile the Java code.
java HelloWorld.java
Run your Java program.
$
java HelloWorld
Hello, World
Choose the default version of Java
If you have multiple versions of Java installed, you can use alternative commands to set the default version.
sudo alternatives --config java
Select Java as the default.
$
sudo alternatives --config java
There is 1 program that provides 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/java/jdk-17/bin/java
Enter to keep the current selection[+], or type selection number:
Video courses for learning the Java programming language:
- Java programming master class for software developers
- Full stack Java developer – Java + JSP + Restful WS + Spring
- Java in-depth: Become a complete Java engineer!
- Java for absolute beginners
- Java programming for complete beginners
- Complete Java certification course
Recommended books:
- Best Java Development Books
Enjoy your Java development on a Linux machine and check out other related guides in our blog.
- Install Node.js on CentOS 8
- Install Ruby on CentOS 8