For those eager to harness the capabilities of Oracle Java 17 on their Linux Mint system, understanding its features and benefits is crucial. Oracle Java 17, a long-term support (LTS) release, is a testament to Oracle’s commitment to innovation and the evolution of the Java programming language. Whether you’re running Linux Mint 21 or its predecessor, Linux Mint 20, this guide will illuminate the path to installing this pivotal Java release.
Oracle Java 17: A Snapshot of Key Features and Enhancements
- Sealed Classes (JEP 397): This update introduces sealed classes and interfaces, allowing developers to dictate which classes or interfaces may extend or implement them, ensuring tighter control over code.
- New macOS Rendering Pipeline (JEP 382): Tailored for macOS users, this feature, based on Apple’s Metal API, optimizes the efficiency of user interfaces on macOS.
- Foreign Function and Memory API (JEP 412): A groundbreaking API that empowers Java programs to interact with functions and data outside the Java heap, ushering in notable performance enhancements.
- Strong Encapsulation of JDK Internals (JEP 403): To bolster Java’s security and maintainability by curbing unauthorized access to the Java Development Kit (JDK) internals.
- Deprecation of the Security Manager (JEP 411): A pivotal shift in Java’s security landscape, this deprecation signals a transition to alternative security measures as developers are urged to adapt.
Oracle Java 17’s rich feature set and improvements highlight Oracle’s unwavering dedication to Java’s growth. These enhancements promise to refine the developer experience, boost performance, and fortify security, solidifying Java’s position in the modern software development landscape.
In the subsequent sections, we’ll delve into how to install Oracle Java 17 on Linux Mint 21 or 20, ensuring you’re equipped to tap into the myriad benefits of this latest Java iteration.
Table of Contents
Install Oracle Java 17 on Linux Mint 21 or 20 via APT PPA
This segment will focus on the step-by-step process to successfully install the Oracle Java 17 JDK. A prominent method to achieve this task involves using the ppa:linuxuprising/java
repository, renowned for its comprehensive Java packages.
Step 1: Add the PPA Repository on Linux Mint
To initiate this process, we must first add the ppa:linuxuprising/java
repository to our system’s list of app sources. Execute the command below in your terminal:
sudo add-apt-repository ppa:linuxuprising/java -y
This command requests the specified PPA repository and integrates it into your system’s database of available software sources. This is essential to make the required Java 17 package available for installation.
Step 2: Update the APT Package List for Oracle Java on Linux Mint
After successfully adding the PPA repository, we must ensure our system’s package lists are current. This involves updating the APT package list to recognize and reflect the newly added PPA repository. To do this, execute the apt update
command as shown:
sudo apt update
This operation will not only ensure the accurate representation of the Java 17 PPA repository in your source list. Still, it will also synchronize your system’s package cache with the server’s most recent updates.
Step 3: Install Oracle Java 17 on Linux Mint 21 or 20
Now that our system knows the new repository, we can install the Oracle Java 17 JDK. Execute the following command to initiate the installation process:
sudo apt install oracle-java17-installer oracle-java17-set-default
This command calls for the apt
package manager to install Oracle Java 17 JDK from the repository we’ve just added. It also ensures that Java 17 becomes the default Java version for your system.
You must accept Oracle’s licensing terms and conditions during the installation process. Ensure to review and accept these terms to facilitate a smooth installation. Accepting these terms is vital to maintain compliance with Oracle’s licensing agreement and circumvent potential installation issues.
Step 4: Confirm Successful Installation of Oracle Java 17 on Linux Mint 21 or 20
Once the installation concludes, verifying the operation’s success is important. This is done by checking the installed Java version on your system. To do so, run the --version
command as follows:
java --version
The output of this command will reveal the Java version currently active on your system.
Install Oracle Java 17 on Linux Mint 21 or 20 via .deb
In the world of Linux, several efficient paths lead to the same destination. If you’re more inclined towards using Debian packages, this section outlines a straightforward approach to installing Oracle Java 17 using the .deb
package.
Step 1: Download the Oracle Java 17 .deb Package on Linux Mint
The first stage of this journey is to acquire the .deb
package for Oracle Java 17. You can conveniently do this through the wget
command, a utility designed for non-interactive downloading files from the web. It supports HTTP, HTTPS, and FTP protocols and retrieves files through HTTP proxies.
Here’s the command to download the Oracle Java 17 .deb
package using wget
:
wget https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.deb
The command above communicates with the specified URL and downloads the Java 17 Debian package directly onto your system. Now, you are ready to move on to the installation process.
Step 2: Install Oracle Java 17 on Linux Mint 21 or 20 via dpkg
Once the .deb
package is downloaded, the next course of action is to install Oracle Java 17 using the dpkg
command. The dpkg
tool provides an easy and efficient way to install, remove, and manage Debian packages on your Linux Mint system.
Before running the dpkg
command, ensure you’re in the directory where the downloaded .deb
package resides. To install Java, execute the following command:
sudo dpkg -i jdk-17_linux-x64_bin.deb
This command calls for the dpkg
utility to install the specified .deb
package. The -i
flag signals that we intend to install a package. The installation process may vary in duration, depending on the package size and your system’s processing speed.
Step 3: Verify the Installation of Oracle Java 17 on Linux Mint
Upon successfully installing Oracle Java 17, confirming that the correct Java version has been set up on your system is prudent. You can do this by checking the installed Java version using the --version
command. Here’s how:
java --version
This command displays the version of Java active on your system. If the installation went as planned, it should indicate Java 17, verifying that Oracle Java 17 JDK is correctly installed.
Install Oracle Java 17 on Linux Mint 21 or 20 via Archive Download
Step 1: Download the Oracle Java 17 Archive on Linux Mint
Your first task is to acquire the Oracle Java 17 archive. An effective way to accomplish this is via the curl
command. This tool lets you download files from a server using multiple protocols, including HTTP and FTP.
Before proceeding, ensure that curl
is installed on your system. If not, you can install it with this command:
sudo apt install curl
Now, armed with curl
, you can download the Oracle Java 17 archive:
curl -O https://download.oracle.com/java/17/latest/jdk-17_linux-x64_bin.tar.gz
This command calls curl
to download the specified archive onto your system.
Step 2: Extract the Oracle Java 17 Archive on Linux Mint
After downloading the archive, you’ll need to extract it. The tar
command, combined with certain flags, can accomplish this. Here’s the command to extract the archive:
tar -xvf jdk-17_linux-x64_bin.tar.gz
This action unpacks the contents of the Oracle Java 17 archive, setting the stage for the subsequent installation steps.
Step 3: Navigate to the Extracted Directory and Install OpenJDK 17 Files on Linux Mint
The next step requires you to maneuver into the directory where the archive was extracted:
cd <directory_name>
Inside the directory, execute the following commands to move the Java 17 files to the appropriate directory:
sudo mkdir -p /usr/local/jdk-17
sudo mv * /usr/local/jdk-17
Step 4: Setup Oracle Java 17 Environment Variables on Linux Mint
After placing the files in the correct directory, setting up the environment variables is time. This process allows your system to recognize where Java is installed and how to interact. To do this, add the following lines to your .bashrc
or .bash_profile
file:
export JAVA_HOME=/usr/local/jdk-17
export PATH=$JAVA_HOME/bin:$PATH
To activate the changes made to your environment variables, you need to source the .bashrc
or .bash_profile
file. This is achieved with the following command:
source ~/.bashrc
Step 5: Verify the Installation of Oracle Java 17 on Linux Mint
As a final step, it’s prudent to confirm that Oracle Java 17 is correctly installed and that your environment variables are correctly set. You can do this by checking the installed Java version and the JAVA_HOME
variable:
java --version
echo $JAVA_HOME
If everything is correctly done, the output will display the Java version and the path to the Java installation, signifying a successful installation and setup process. This manual installation gives you fine-grained control over your Java development environment, which can be advantageous based on your specific use case.
Test Java Installation: Create Java Application on Linux Mint 21 or 20
Having successfully installed Oracle Java 17 on your Linux Mint system, the next imperative step is to verify the functionality of your setup. A preferred method is to author a small yet fun Java application. This validates the installation and introduces you to creating, compiling, and executing Java applications on Linux Mint.
Step 1: Scripting the First Java Application on Linux Mint
You must create a new Java file using a text editor to kick things off. The nano
text editor is a common choice due to its simplicity and ease of use. You can create a new file, named Greeting.java
, using the following command:
sudo nano Greeting.java
In the newly created file, you can script a Java application. Here’s an example of a straightforward application that will display a jovial greeting when executed:
public class Greeting {
public static void main(String[] args) {
System.out.println("Greetings from the Linux Mint universe!");
}
}
Save the file by pressing CTRL+O
and then exit the text editor using CTRL+X
.
Step 2: Compile and Execute the Java Application on Linux Mint
Once your code is ready, it’s time to compile it. Java runs a two-step process: first compiling to bytecode, then executing the bytecode. This is done with the javac
command:
javac Greeting.java
If your code doesn’t contain any errors, this command will create a file called Greeting.class
containing the Java bytecode.
Next, to execute the bytecode and see your crafted message, use the java
command:
java Greeting
You should see the output: Greetings from the Linux Mint universe!
, indicating that the application has successfully run and your Java installation functions correctly.
Step 3: Exploring Further With a Second Java Application
To further validate the functionality of your Java development environment, creating and testing another Java application is advisable. This activity solidifies your understanding and confidence in handling Java on Linux Mint.
Create another file, Farewell.java
, and insert this simple piece of code:
public class Farewell {
public static void main(String[] args) {
System.out.println("Until next time, Linux Mint universe!");
}
}
Compile and run this program the same way as before:
javac Farewell.java
java Farewell
The output will be: Until next time, Linux Mint universe!
, once again, confirming the successful operation of your Java development environment.
By creating and testing these two simple applications, you’ve proven your Java environment’s functionality and become more acquainted with creating, compiling, and running Java programs on Linux Mint. You’re now ready to tackle more complex Java development tasks.
Closing Remarks
This comprehensive guide illustrated the steps to set up Oracle’s Java 17 version on a Linux Mint system. This highly sought-after version of Java was installed using a manual method, which enables enhanced control and customization options tailored to the user’s specific needs and preferences. We also highlighted the importance of testing the setup post-installation through the creation and execution of fun Java applications. The successful execution of these applications signifies that you have correctly installed Java on your Linux Mint system and are ready to explore the Java world further.