Как установить java 17 на ubuntu
This topic describes the installation procedures of the JDK on the Linux platform, along with the system requirements.
General Notes About Installing the JDK on Linux Platforms from Archive Files
Installing the JDK automatically creates a directory called jdk–feature.interim.update.patch where feature ( 17 ),interim, update, and patch represent corresponding values of version information.
If you install JDK in a specific location such as /opt , you must log in with root credentials to gain the necessary permissions. If you do not have the root access, either install the JDK in your home directory or a sub directory for which you have the write permissions.
If you install the software in a directory that contains a sub directory named jdk– 17 .interim.update.patch , the new software overwrites files of the same name in that directory. Ensure that you rename the old directory if it contains files that you would like to keep.
Installing the JDK from archive files doesn’t configure the backing store for the system node of Java Preferences API ( java.util.prefs Java package). If this functionality of the JDK is required, you need to manually configure it by making sure either /etc/.java/.systemPrefs or jdk– 17 .interim.update.patch/.systemPrefs directory exists.
General Notes About Installing the JDK on Linux Platforms from RPM packages
This topic describes general information about installing JDK 17 from RPM packages on Linux platforms.
You can install only one version of JDK of the same feature release. If you try to install the newer version of the same feature release while the older version exists, the installer uninstalls the older version and installs the new version. For example, you can’t install jdk- 17 and jdk- 17 .0.1 simultaneously. If you attempt to install jdk- 17 .0.1 after jdk- 17 is installed, the installer uninstalls jdk- 17 and installs jdk- 17 .0.1 .
All versions of JDK of the same feature release are installed in /usr/lib/jvm/jdk- 17 -oracle-<ARCH> directory, where <ARCH> equals x64 or aarch64 . Additionally /usr/java/jdk- 17 symbolic link pointing to the installation directory is created for backward compatibility.
If you install an older version of a JDK when the newer version of the same feature family already exists, an error is displayed, prompting you to uninstall a newer JDK version if an older version has to be installed.
You must log in with root credentials to install or update JDK.
By default, the installation script configures the system such that the backing store for the system node of Java Preferences API (java.util.prefs Java package) is configured in /etc/.java/.systemPrefs directory.
The JDK installation is integrated with the alternatives framework. After installation, the alternatives framework is updated to reflect the binaries from the recently installed JDK. Java commands such as java , javac , javadoc , and javap can be called from the command line.
Using the java -version command, you can confirm the default (recently installed) JDK version.
System Requirements for Installing JDK on Linux Platforms
See Oracle JDK Certified Systems Configurations for information about supported platforms, operating systems, and browsers.
JDK Installation Instruction Notation for Linux Platforms
JDK installers now support only one version of any Java feature release. You can’t install multiple versions of the same feature release.
If you install an older version of a JDK when the newer version of the same feature family already exists, an error is displayed, prompting you to uninstall a newer JDK version if an older version has to be installed.
Linux x64 systems: jdk- <FEATURE> _linux-x64_bin.tar.gz
Linux aarch64 (64-bit ARM) systems: jdk- <FEATURE> _linux-aarch64_bin.tar.gz
Installing the JDK on Linux from Archive Files, RPM Packages and Oracle Linux Repositories
You can install the JDK on a Linux platform from archive files, downloadable Red Hat Package Manager (RPM) packages files, or RPM packages from Oracle Linux (OL) repositories.
Installation can be performed by using one of the following processes:
From archive files ( .tar.gz ): This allows you to install a private version of the JDK for the current user into any location, without affecting other JDK installations. However, it may involve manual steps to get some of the features to work. See the following table for the options available for downloading and installing the JDK from archive files. The bundles are available for Linux x64 and Linux aarch64 (64-bit ARM) systems. Install the required bundle.
From downloadable RPM packages ( .rpm ): This allows you to perform a system-wide JDK installation on RPM-based Linux platforms for all users, and requires root access. See the following table for the options available for downloading and installing the JDK from Linux x64 and Linux aarch64 (64-bit ARM) RPM packages.
From Oracle Linux repositories : This allows you to perform a system-wide JDK installation on OL platforms starting from OL7 for all users, and requires root access. JDK RPM packages in Oracle Linux RPM repositories are available for x64 and aarch64 (64-bit ARM) OL platforms. Explicit download of JDK RPM packages is not required, the package manager will do it automatically for you.
Table 3-1 Difference between Generic Linux and OL platforms
JDK image is split into two packages: jdk- 17 -headless and jdk- 17 -headful .
- jdk- 17 -headless is a headless Java Runtime for running non-GUI applications.
- jdk- 17 -headful is headful Java Runtime and Development Tools for developing and running all types of applications.
jdk- 17 -headful package requires jdk- 17 -headless package. When these packages are installed together, they provide the same functionality as the jdk- 17 package for Generic Linux Platforms.
jdk- 17 -headless package registers java group with the alternatives framework.
jdk- 17 -headful package registers javac group with the alternatives framework.
Downloading the JDK Installer
Access Java SE Downloads page and click Accept License Agreement . Under the Download menu, click the Download link corresponding your requirement.
The following table lists the options and instructions for downloading and installing the JDK 17 release on a Linux platform:
| Download File | Instructions | Architecture (CPU Type) | Who Can Install |
|---|---|---|---|
| For Linux x64 systems: jdk- 17 .interim.update.patch_linux-x64.tar.gz | Installing the 64-Bit JDK on Linux Platforms | Intel — 64-bit | Anyone |
| For Linux aarch64 (64-bit ARM) systems: jdk- 17 .interim.update.patch_linux-aarch64.tar.gz | Installing the 64-Bit JDK on Linux Platforms | ARM — 64-bit | Anyone |
| For Linux x64 systems: jdk- 17 .interim.update.patch_linux-x64.rpm | Installing the 64-Bit JDK on RPM-Based Linux Platforms | Intel — 64-bit RPM-based Linux | Root |
| For Linux aarch64 (64-bit ARM) systems: jdk- 17 .interim.update.patch_linux-aarch64.rpm | Installing the 64-Bit JDK on RPM-Based Linux Platforms | ARM — 64-bit RPM-based Linux | Root |
Installing the 64-Bit JDK on Linux Platforms
You can install the JDK for 64-bit Linux from an archive file ( .tar.gz ). The .tar.gz archive file (also called a tarball) is a file that can be uncompressed and extracted in a single step.
- Download the required file:
- For Linux x64 systems: jdk- 17 .interim.update.patch_linux-x64_bin.tar.gz . For example jdk- 17 _linux-x64_bin.tar.gz
- For Linux aarch64 (64-bit ARM) systems: jdk- 17 .interim.update.patch_linux-aarch64_bin.tar.gz . For example, jdk- 17 _linux-aarch64_bin.tar.gz
Before you download a file, you must accept the license agreement. Anyone (not only root users) can install the archive file in any location having write access.
$ tar zxvf jdk- 17 _linux-x64_bin.tar.gz
$ tar zxvf jdk- 17 _linux-aarch64_bin.tar.gz
The Java Development Kit files are installed in a directory named jdk- 17 .interim.update.patch .
Installing the 64-Bit JDK on RPM-Based Linux Platforms
You can install the JDK on 64-bit RPM-based Linux platforms, such as Red Hat and SuSE by using a downloadable RPM package file ( .rpm ) in the system location.
You can install the JDK using a downloadable RPM package file on an OL system too, but the preferred way to install the JDK on OL systems is from Oracle Linux RPM repositories.
- Download the required file:
- For x64 systems: jdk- 17 .interim.update.patch_linux-x64_bin.rpm . For example, jdk- 17 _linux-x64_bin.rpm
- For aarch64 (64-bit ARM) systems: jdk- 17 .interim.update.patch_linux-aarch64_bin.rpm . For example, jdk- 17 _linux-aarch64_bin.rpm
Before you download a file, you must accept the license agreement.
$ sudo rpm -ivh jdk- 17 _linux-x64_bin.rpm
$ sudo rpm -ivh jdk- 17 _linux-aarch64_bin.rpm
Upgrade the required package using the following command:
$ sudo rpm -Uvh jdk- 17 _linux-x64_bin.rpm
$ sudo rpm -Uvh jdk- 17 _linux-aarch64_bin.rpm
JDK 17 can coexist with other feature releases of JDK. For each feature release, a separate directory is created, the default directory being /usr/lib/jvm/jdk- <FEATURE> -oracle-<ARCH> . For example, JDK 17 releases for x64 will be installed in /usr/lib/jvm/jdk- 17 -oracle-x64 directory.
Sorry, you have been blocked
This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.
What can I do to resolve this?
You can email the site owner to let them know you were blocked. Please include what you were doing when this page came up and the Cloudflare Ray ID found at the bottom of this page.
Cloudflare Ray ID: 7d4fed1d4fe02319 • Your IP: Click to reveal 88.135.219.175 • Performance & security by Cloudflare
How to install Java JDK 17 on ubuntu 20.04
![]()
Installing Java JDK 17 on Ubuntu 20.04 is a straightforward process. By following a few simple steps, you can set up the latest Java Development Kit on your system. This guide will help you install JDK 17 and ensure that it is properly configured for your Ubuntu 20.04 environment.
To install Java JDK 17 on Ubuntu 20.04, you can download the JDK package from the official Oracle website for developers. Navigate to the Oracle website, locate the JDK 17 download page, and choose the appropriate package for your operating system. Make sure to select the Linux version compatible with Ubuntu 20.04.
Extract the contents of a tar.gz file using the following command:
Move the jdk-17.0.7 directory to /usr/local using the following command
Symbolically link Java and Javac executables with the following commands:
To check the Java and Javac versions, you can use the following commands:
How to install Java 17 in Ubuntu 20.04
In this guide we are going to explore how to install Java Runtime Environment (JRE) and the Java Developer Kit (JDK) in Ubuntu 20.04.
Java and the JVM (Java’s virtual machine) are required for many kinds of software, including Tomcat, Jetty, Glassfish, Cassandra and Jenkins.
Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. Java was developed by Sun Microsystems (which is now the subsidiary of Oracle) in the year 1995. James Gosling is known as the father of Java.
Prerequisites
- Up to date Ubuntu 20.04 system
- Root access or user with sudo access
- Internet access from the server
Table of content
- Ensuring that the server is up to date
- Installing java
- Testing the installation
- Toggling multiple Java versions
- Configuring the Environmental Variable
Ensuring that the server is up to date
Before proceeding, let us make sure that the server packages and repositories are up to date. Use these commads to achieve the goal:
If there are packages to upgrade, the above comand may take a couple of minutes.
Let us also install some common packages that we might need. I use vim text editor, please make sure its installed using this command:
Installing Java
Check whether java is installed in your sytem.
If you see java: command not found then it means that java is not installed. If java is installed, that command will print out the java version
Ubuntu 20.04’s default repository included Java 17. This is the easiest way to install the JDK using the apt package manage.
You can search java using this command:
Run the following command to install Java 17 on Ubuntu 20.04. We will install both JDK and JRE in order to run Java applications and applets.
Once the installation is completed, run the following command in order to check if it works properly. If everything works fine, you should get an output similar to the one shown below.
To verify if the JDK is installed properly, we will check the version of javac, which is the Java compiler.
Testing the installation
Let us test that Java 17 is installed properly in this step by creating a simple script that prints out Java is installed properly .
Create the directory and switch to it
I use vim to create and edit text files in my system. Use the text editor of your choice in this step. I will create a file Simple.java using this command:
Add these content to the file
Now that we have created our program, we need to compile the Java source code into bytecode (class file) using the javac compiler.
You will get a new file called Simple.class , which is the compiled Java class file.
The command above will only compile the Java source code into bytecode. In order to run the program, we run the java command with the name of our class file as an argument.
If everything works well, you’ll see a message “ Citizix — Java is installed properly ” on the screen.
Toggling multiple Java versions
If you have multiple versions of Java installed in your system, you can configure which version the java command defaults to.
Use this command to configure that
You will be given a list of available java installations. In this case I have both java 11 and java 17 installed. The default version is marked with an asterisk(*). You can opt to use a different version by entering the number in the prompt.
In the above, I entered 1 to the promp to choose Java 11. Let us confirm the java version now:
Configuring the Environmental Variable
Some Java applications require the JAVA_HOME environmental variable in order to run properly. Some programs are very specific in how they are executed. If JAVA_HOME isn’t set, you’ll get an error. Setting JAVA_HOME will prevent this problem from arising.
To check which Java installations and paths exist, use this command:
In my case, I get the Java installation binary path to be this /usr/lib/jvm/java-17-openjdk-amd64/bin/java
We are going to set this path in an enviroment file /etc/environment where all the apps can access.
Open the file with vim:
Now we need to add a line exporting the Java home to the file like this export JAVA_HOME=. making the value to be the path we got for our Java installation:
This file will set the JAVA_HOME path of OpenJDK 17 as environmental variables for all users in the system.
To apply the change, run the following command.
To verify that the path variable has been applied, run the following command.
The path should be set to the path of OpenJDK 17, which you have copied above. This is the value in my case:
From now on, you don’t have to set the JAVA_HOME path every time when using Java programs. Also, if you want to use other OpenJDK versions instead of 17, adapt the path accordingly.
Conclusion
In this tutorial, you have learned how to install Java 17 on a Ubuntu 20.04 system. If you need further information about the Java language, please refer to its official documentation.