2 ways to install Oracle Java 17 on Ubuntu 20.04 | 22.04 LTS
Oracle Java 17 cannot be installed on Ubuntu 20.04 or 22.04 LTS using the default main repository of these Linux. Therefore, here we will know the steps to configure the same using the command terminal.
What is the main difference between Oracle Jave and OpenJDK?
Well, if you don’t particularly want Oracle’s Java, the OpenJDK is still available with the latest and old versions to install on Ubuntu (through the main repository). But for those who aren’t exactly familiar with the difference between Oracle Java and OpenJDK, let’s talk a bit about that.
Oracle JDK 11, Oracle JDK Java 8, and Oracle JRE with Java Web Start in Java 8 were licensed under the OTN License Agreement for Java SE. Therefore, it is free for personal and developmental use, but there are certain restrictions for commercial and commercial or production use, which means if anyone wants to use any of them for any purpose. commercial, it must obtain a commercial license. However, since Java 17, Oracle has made it free for all users. While OpenJDK has the GNU General Public License (GNU GPL), it is a open source version Oracle Java with the same capabilities but free for everyone without any restrictions. This is the reason why most Linux distributions provide OpenJDK through its main repository by default.
What is the Java programming language?
Java is first and foremost a programming language that pupils and students often learn in computer classes. Initially, the JAVA belongs to the company “Sun Microsystems”, but later it was acquired by Oracle in 2010.
It has been widely used by developers or programmers to quickly create applications or scripts. Well, Java is one of the object oriented programming languages. This means that the code of the associated program is structured into classes and objects. For example, an object of the class “pen” can be created. The class defines the properties of the “pen”: color, length, shape. A concrete object is an achievement of the class, for example a fountain pen with a diameter of “1.7 cm” and the color “black”.
Java is mainly used for programming web applications, desktop applications, and applications. For example, applications for Google’s Android operating system are developed in Java.
Steps to Install Oracle Java 17 (JDK / JRE) on Ubuntu 20.04 | 22.04 LTS
1st method using the Tar file
1. Download the Oracle Java 17 LTS Deb file
The Linux Deb binary for easily installing Java 17 is available on the official Oracle site, visit it. On the page, click on the Deb file to download it using the browser or just right click and copy its link. After that use wget in terminal to download the same.
sudo apt install wget -y wget past-link
2. Install Oracle Java JDK 17 on Ubuntu 20.04 | 22.04 LTS
Now, once the Debian package of the latest version of Java 17 is on your system, use the APT package manager to install it.
sudo apt install ./jdk-17_linux-x64_bin.deb
To go out:
Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'jdk-17' instead of './jdk-17_linux-x64_bin.deb' The following additional packages will be installed: alsa-topology-conf alsa-ucm-conf libasound2 libasound2-data libbsd0 libc6-i386 libc6-x32 libfreetype6 libpng16-16 libx11-6 libx11-data libxau6 libxcb1 libxdmcp6 libxext6 libxi6 libxrender1 libxtst6 x11-common Suggested packages: libasound2-plugins alsa-utils
3. Notify the system of the new installation of Oracle Java
As we installed it manually, let the system know that we recently added a new version of Java to a particular directory or path. So, that he might recognize the same.
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk-17/bin/java" 1
4. Set default Java to Ubuntu 20.04 / 22.04 (optional)
If you do not want to set Oracle Java 17 as the system-wide default Java, you can skip this step. Otherwise, run the given command:
sudo update-alternatives --set java /usr/lib/jvm/jdk-17/bin/java
In the future, if you want to set another version as the default version, just change the folder path to Java binary as shown in the command above.
5. Check the version of Oracle JDK / JRE
Finally, to confirm that Oracle Java 17 is running the given syntax:
6. Uninstall or remove
Well, if you don’t need this version of JAVA anymore, we can remove it with a simple command:
sudo apt purge jdk-17
# 2nd method using PPA
To note: The PPA given here is not from Ubuntu or Oracle, instead of a third party or developer, so it will not be recommended for production systems. Since we don’t know when the PPA maintainer will drop it. However, the advantage of using PPA is that you won’t have to update Java manually in the future. Running the system update and upgrade command will do this for you.
Add PPA Repository for Oracle JDK 17 Installer
Here is the command to add the PPA repository for Oracle JDK 17:
sudo apt install software-properties-common
sudo add-apt-repository ppa:linuxuprising/java -y
Perform system update
To properly integrate the added PPA repository, run the update system command again:
sudo apt update
Command to install JDK-17 on Ubuntu 20.04 | 22.04 Linux
Once the repository is added, let’s run the APT Package Manager command to install Oracle Java 17.
If you want to set this version as the default version after installation, run this command
sudo apt install oracle-java17-installer --install-recommends
While those who want to install Java 17 but don’t want to set it as the default version can opt for this one:
sudo apt install oracle-java17-installer --no-install-recommends
Accept the terms
Check the version:
To delete or delete it
sudo apt autoremove oracle-java17-installer oracle-java17-set-default --purge
Where to delete PPA repository use:
sudo add-apt-repository --remove ppa:linuxuprising/java -y
â¢ Add a repository to install MySQL 5.7 on Ubuntu 20.04 LTS Linux
â¢ How to install MySQL 8.0 Server on Debian 11 Bullseye
â¢ Install the VNC server on Ubuntu 20.04 | 04/18
â¢ 2 ways to install Chrome browser on Ubuntu