How to install the JDK on Ubuntu Linux
I am trying to install the Java Development Kit (JDK) on Ubuntu Linux distribution, but I am unable to install it. What are the steps to install it on Ubuntu?
74k 34 34 gold badges 196 196 silver badges 348 348 bronze badges
asked Feb 9, 2013 at 12:51
user2057084 user2057084
6,049 3 3 gold badges 13 13 silver badges 7 7 bronze badges
Which JDK version? Java6 or 7? 32 or 64 bit version?
Feb 9, 2013 at 12:59
Mar 21, 2014 at 20:58
Apr 8, 2018 at 9:59
34 Answers 34
How to install Open JDK (Java developement kit) in Ubuntu (Linux)?
- Open Terminal from Application Dash or press Ctrl + Alt + T
- Update repository:
sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier sudo apt update
apt search openjdk
sudo apt install openjdk-8-jdk sudo apt install openjdk-8-source #this is optional, the jdk source code
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
760 1 1 gold badge 4 4 silver badges 17 17 bronze badges
answered Feb 9, 2013 at 13:06
Dhaval Shah Dhaval Shah
9,072 2 2 gold badges 15 15 silver badges 21 21 bronze badges
I copied your «export PATH=» . command and screwed up my box. Please correct it to: «export PATH=$PATH:/usr/lib/jvm/java-6-openjdk/bin»
Jun 27, 2013 at 23:08
I’d replace export PATH=$PATH:/usr/lib/jvm/java-6-openjdk/bin with export PATH=$PATH:$JAVA_HOME/bin , which is more DRY
Dec 18, 2013 at 20:28
just replace everywhere java-6-openjdk to java-7-openjdk if you want to install java7
May 30, 2014 at 12:57
You better check what is the actual folder. In my case it was: /usr/lib/jvm/java-7-openjdk-amd64
Jan 31, 2015 at 20:21
For ubuntu 16.04 use openjdk-8-jdk There is no openjdk-7-jdk see here
Oct 25, 2016 at 5:32
The following used to work before the Oracle Java license changes in early 2019.
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer
The PPA is discontinued, until the author finds a workaround for the license issues.
1,091 1 1 gold badge 14 14 silver badges 31 31 bronze badges
answered Jan 2, 2014 at 13:22
Julio Marins Julio Marins
10.2k 8 8 gold badges 49 49 silver badges 54 54 bronze badges
For more information: webupd8.org/2012/01/…
Feb 3, 2014 at 16:39
This is what I used. If you want java6 : sudo apt-get install oracle-java6-installer . if you want java8 : sudo apt-get install oracle-java8-installer . If you have multiple java installed on your system, you can select with : sudo update-alternatives —config java
Jun 13, 2014 at 22:27
This is the easiest answer and working with all jdk versions, just replace java7 with java6, 8 or 9 and you will be able to install the version you want!
Sep 14, 2016 at 18:57
Is there a work around for the first step? The ppa no longer works.
Mar 11, 2018 at 8:02
As of March 2019 the ppa was disabled and now 99% of the answer regarding this issue around the internet cannot be used anymore.
Apr 29, 2019 at 12:35
You can install Oracle’s JDK 1.7 fairly easily too; as an example this is how to install JDK 1.7.0_13;
- Download the JDK from Oracle’s site. The download to the newest version is always linked from http://java.oracle.com.
cd /usr/local tar xzf
As your normal user, add or change these two lines in your ~/.profile to point to the installation;
export JAVA_HOME=/usr/local/jdk1.7.0_13 export PATH=$PATH:$JAVA_HOME/bin
If it’s an update, you may also want to remove the old java installation directory in /usr/local .
Log out and in again (or do . ~/.profile ), and everything should just work.
The downside with Oracle’s JDK is that it won’t update with the rest of your system like OpenJDK will, so I’d mostly consider it if you’re running programs that require it.
308k 44 44 gold badges 310 310 silver badges 485 485 bronze badges
answered Feb 9, 2013 at 13:55
Joachim Isaksson Joachim Isaksson
178k 26 26 gold badges 285 285 silver badges 299 299 bronze badges
do i need to give the path to the downloaded folder in tar xzf command
Nov 16, 2013 at 4:29
@Subash you need the downloaded file to be in th /usr/local directory before running the tar xzf command. To get that, cd to the path where your downloaded file is and run: sudo mv
Nov 18, 2013 at 9:29
Hi, new to linux, I just have to extract the archive and it’s installed?
Mar 4, 2016 at 9:45
You may also need to define aliases for JVM and Java Compiler and put them inside your ~/.profile file: alias java=’$JAVA_HOME/bin/java’ and alias javac=’$JAVA_HOME/bin/javac’
Apr 26, 2016 at 23:13
just download the .rpm and use alien to install it. sudo alien -i jdk-xxxxx.rpm
Apr 17, 2018 at 14:12
In case you have already downloaded the ZIP file follow these steps.
Run the following command to unzip your file.
tar -xvf ~/Downloads/jdk-7u3-linux-i586.tar.gz sudo mkdir -p /usr/lib/jvm/jdk1.7.0 sudo mv jdk1.7.0_03/* /usr/lib/jvm/jdk1.7.0/ sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
After installation is complete, set environment variables as follows.
Edit the system path in file /etc/profile :
sudo gedit /etc/profile
Add the following lines at the end.
JAVA_HOME=/usr/lib/jvm/jdk1.7.0 PATH=$PATH:$HOME/bin:$JAVA_HOME/bin export JAVA_HOME export PATH
1,053 2 2 gold badges 17 17 silver badges 34 34 bronze badges
answered Sep 24, 2013 at 3:43
Pratap Singh Pratap Singh
4,637 1 1 gold badge 23 23 silver badges 24 24 bronze badges
Thanks! I was looking for the method using update-alternatives
Sep 27, 2014 at 14:28
Where did the JRE_HOME variable come from?
Apr 26, 2016 at 11:44
Note: WebUpd8 team’s PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn’t have any Java files. More information can be found on PPA’s page on Launchpad. Hence the below method no longer works and exists because of historical reasons.
If you want to install the latest JDK 1.8, use the webupd8team PPA.
Add the repository in your system:
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update
You can now install Oracle Java 8 using the following command:
sudo apt-get install oracle-java8-installer
This ppa repository also provides a package to set environment variables automatically. Just type:
sudo apt-get install oracle-java8-set-default
189 3 3 silver badges 12 12 bronze badges
answered Mar 17, 2015 at 17:38
1,941 2 2 gold badges 22 22 silver badges 50 50 bronze badges
OpenJDK is OK for the most cases, but Oracle JDK can be required for some bank client applications (my case) — I can’t use OpenJDK.
I’m surprised that I don’t see any answer with the default method (repository without external PPAs) in Ubuntu 12.10+ for Oracle’s JDK — I will try to describe it.
- Install JavaPackage: sudo apt-get install java-package
- Download Oracle JDK from Oracle downloads page
- Make a Debian package from the downloaded .tar.gz archive: make-jpkg jdk-YOUR_VERSION-linux-PLATFORM.tar.gz This command will produce a .deb package.
- Install the package in your favourite way (for example, sudo dpkg -i oracle-java8-jdk_8u40_amd64.deb )
It’s the officially supported way from Debian developers for installing Oracle JDK, and I suppose it’s very simple.
30.8k 22 22 gold badges 106 106 silver badges 131 131 bronze badges
answered Mar 4, 2015 at 20:04
4,765 1 1 gold badge 39 39 silver badges 42 42 bronze badges
This is easily the best answer. Took a couple minutes and gave the official JDK, since some apps don’t like OpenJDK too much.
Jul 24, 2016 at 21:24
can we add the documentation with that method?
Aug 19, 2017 at 23:19
note: you can also install the documentation easily this way. this should be the most recommended way of installing java.
Aug 20, 2017 at 5:28
Note: WebUpd8 team’s PPA has been discontinued with effective from April 16, 2019. Thus this PPA doesn’t have any Java files. More information can be found on PPA’s page on Launchpad. Hence the below method no longer works and exists because of historical reasons.
Installing Java 8 on Ubuntu
First you need to add webupd8team Java PPA repository in your system and install Oracle Java 8 using following set of commands.
$ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-java8-installer
Verify Installed Java Version
After successfully installing Oracle Java using the above steps, verify the installed version using the following command.
$ java -version java version "1.8.0_77" Java(TM) SE Runtime Environment (build 1.8.0_77-b03) Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
###Configuring the Java environment
In Webupd8 ppa repository also providing a package to set environment variables, Install this package using following command.
$ sudo apt-get install oracle-java8-set-default
189 3 3 silver badges 12 12 bronze badges
answered Apr 23, 2016 at 0:22
868 14 14 silver badges 33 33 bronze badges
Roughly the same thing worked for Java9: sudo apt-get install oracle-java9-installer
Feb 15, 2018 at 18:01
sudo apt-get install default-jdk
answered Dec 22, 2014 at 16:10
saharsh-jain saharsh-jain
496 7 7 silver badges 12 12 bronze badges
This is for Ubuntu 18.04+ only, I think.
Jan 15, 2019 at 18:35
For Ubuntu 10.04 LTS, the sun-java6 packages have been dropped from the Multiverse section of the Ubuntu archive. It is recommended that you use openjdk-6 instead.
If you can not switch from the proprietary Sun JDK/JRE to OpenJDK, you can install sun-java6 packages from the Canonical Partner Repository. You can configure your system to use this repository via command-line:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo apt-get update sudo apt-get install sun-java6-jre sun-java6-plugin sudo update-alternatives --config java
For Ubuntu 10.10, the sun-java6 packages have been dropped from the Multiverse section of the Ubuntu archive. It is recommended that you use openjdk-6 instead.
If you can not switch from the proprietary Sun JDK/JRE to OpenJDK, you can install sun-java6 packages from the Canonical Partner Repository. You can configure your system to use this repository via command-line:
sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner" sudo apt-get update sudo apt-get install sun-java6-jre sun-java6-plugin sudo update-alternatives --config java
How to install JDK 11 under Ubuntu?
So Java 11 is out. Does anybody know how to install it (OpenJDK from Oracle) from the command line? I would like to see something like it was before for Oracle Java 10:
sudo add-apt-repository ppa:linuxuprising/java sudo apt-get update sudo apt-get install oracle-java10-installer
P. S. In the similar question proposed instruction:
sudo apt-get install openjdk-11-jdk
doesn’t work.
1,240 13 13 silver badges 22 22 bronze badges
asked Sep 25, 2018 at 18:42
Dmitriy Dumanskiy Dmitriy Dumanskiy
12k 9 9 gold badges 38 38 silver badges 57 57 bronze badges
What error do you get when you attempt to sudo apt-get install openjdk-11-jdk ?
Sep 25, 2018 at 18:45
Here are the «official» installation instructions for Linux. There’s an RPM ( yum ), or you can install manually from archive libraries. But apparently no Debian apt-get (yet). Q: So why not just install from tar.gz? See also update-alternatives
Sep 25, 2018 at 18:49
@Mureinik «E: Unable to locate package openjdk-11-jdk» on Ubuntu 16.04
Sep 25, 2018 at 18:52
@Mureinik At the moment this package still installs Java 10. It will be updated in the next days I assume to provide Java 11.
Sep 26, 2018 at 18:41
@Robert next days, next weeks, next months.
Oct 23, 2018 at 13:49
12 Answers 12
Now it is possible to install openjdk-11 this way:
sudo apt-get install openjdk-11-jdk
(Previously it installed openjdk-10, but not anymore)
3,726 34 34 silver badges 56 56 bronze badges
answered Oct 23, 2018 at 13:48
9ilsdx 9rvj 0lo 9ilsdx 9rvj 0lo
8,217 10 10 gold badges 41 41 silver badges 78 78 bronze badges
Is this Oracle build or from adoptOpenJDK?
Nov 13, 2018 at 20:22
Actually I think it is the Oracle OpenJDK one. I think Debian/Ubuntu just download the tarball from the Oracle OpenJDK release, add a few patches on top and build their packages.
Dec 14, 2018 at 20:09
If you’re not using Java in any GUI environment you might prefer installing openjdk-11-jdk-headless . Or if all you want is to run something, not compile, openjdk-11-jre[-headless] might suit you as well.
Dec 27, 2018 at 17:33
I had to run sudo add-apt-repository ppa:openjdk-r/ppa first to add the repository.
May 23, 2020 at 21:20
Same here. Also sudo apt-get update to update the repository. Then sudo apt-get install openjdk-11-jdk worked.
Jul 1, 2020 at 15:20
To install Openjdk 11 in Ubuntu, the following commands worked well.
sudo add-apt-repository ppa:openjdk-r/ppa sudo apt-get update sudo apt install openjdk-11-jdk
answered Nov 21, 2018 at 9:26
1,411 1 1 gold badge 8 8 silver badges 7 7 bronze badges
On Pi first command gives me: aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Raspbian/stretch
Nov 17, 2019 at 15:15
Worked for me for openjdk-11-jdk-headless
Jul 27, 2020 at 21:07
sudo apt-get install openjdk-11-jdk
java -version
to make sure java version is 1.11.x, if found old one or different, check below command to see the available jdks,
update-java-alternatives --list
you should see something like below,
java-1.11.0-openjdk-amd64 1111 /usr/lib/jvm/java-1.11.0-openjdk-amd64 java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64
you can see java 1.11 available from above list, use below command to set java 11 to default,
sudo update-alternatives --config java
for above command, you will get something like below and also, will ask for an option to set,
There are 3 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 manual mode *2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode 3 /usr/lib/jvm/jdk1.8.0_211/bin/java 0 manual mode Press to keep the current choice[*], or type selection number:
you can select desired selection number, my case it’s 0
sudo update-alternatives --config javac
will result something like below,
There are 3 choices for the alternative javac (providing /usr/bin/javac). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/javac 1111 auto mode 1 /usr/lib/jvm/java-11-openjdk-amd64/bin/javac 1111 manual mode *2 /usr/lib/jvm/java-8-openjdk-amd64/bin/javac 1081 manual mode 3 /usr/lib/jvm/jdk1.8.0_211/bin/javac 0 manual mode Press to keep the current choice[*], or type selection number:
in my case, it’s 0 again
after above steps, try
java -version
it will display something like below,
openjdk version "11.0.4" 2019-07-16 OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3) OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu218.04.3, mixed > mode, sharing)
Как установить jdk на 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
- General Notes About Installing the JDK on Linux Platforms from RPM packages
- System Requirements for Installing JDK on Linux Platforms
- Installing the JDK on Linux from Archive Files, Debian Packages, RPM Packages, and Oracle Linux Repositories
General Notes About Installing the JDK on Linux Platforms from Archive Files
This topic describes general information about installing JDK 17 on Linux platforms.
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- directory, where 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.
In addition, you can check which specific RPM package provides the java files:
$ rpm -q --whatprovides java
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.
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 .
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- _linux-x64_bin.tar.gz
This string becomes:
jdk-17_linux-x64_bin.tar.gz
Linux aarch64 (64-bit ARM) systems: jdk- _linux-aarch64_bin.tar.gz
This string becomes:
jdk-17_linux-aarch64_bin.tar.gz
Installing the JDK on Linux from Archive Files, Debian Packages, RPM Packages, and Oracle Linux Repositories
You can install the JDK on a Linux platform from archive files, debian packages, 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 Debian packages ( .deb ): This allows you to perform a system-wide JDK installation on Debian-based Linux platforms, and requires root access.
- 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.
JDK RPM packages for Generic Linux platforms and Oracle Linux platforms differ. The following table lists the differences:
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.deb | Installing the 64-Bit JDK Package on Debian-based Linux Platforms | Intel — 64-bit RPM-based Linux | Root |
| 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.
To install the 64-bit JDK on a Linux platform:
- 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 OR $ 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 Package on Debian-based Linux Platforms
You can install the JDK Debian package for 64-bit Linux from the ( .deb ) file.
To install the 64-bit JDK Debian package on a Linux platform:
- Download the required file:
jdk- 17 .interim.update.patch_linux-x64_bin.deb . For example jdk- 17 _linux-x64_bin.deb
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.
$ sudo dpkg -i jdk- 17 _linux-x64_bin.deb
The Java Development Kit files are installed into /usr/lib/jvm/jdk-
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.
Ensure that you have the root user access. You can do this by running the command su and entering the superuser password.
To install the 64-bit JDK on an RPM-based Linux platform:
- 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 OR $ 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 OR $ sudo rpm -Uvh jdk- 17 _linux-aarch64_bin.rpm
Note: 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-
Как установить jdk на 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
- General Notes About Installing the JDK on Linux Platforms from RPM packages
- System Requirements for Installing JDK on Linux Platforms
- Installing the JDK on Linux from Archive Files, Debian Packages, RPM Packages, and Oracle Linux Repositories
General Notes About Installing the JDK on Linux Platforms from Archive Files
This topic describes general information about installing JDK 21 on Linux platforms.
Installing the JDK automatically creates a directory called jdk–feature.interim.update.patch where feature ( 21 ),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– 21 .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– 21 .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 21 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- 21 and jdk- 21 .0.1 simultaneously. If you attempt to install jdk- 21 .0.1 after jdk- 21 is installed, the installer uninstalls jdk- 21 and installs jdk- 21 .0.1 .
All versions of JDK of the same feature release are installed in /usr/lib/jvm/jdk- 21 -oracle- directory, where equals x64 or aarch64 . Additionally /usr/java/jdk- 21 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.
In addition, you can check which specific RPM package provides the java files:
$ rpm -q --whatprovides java
System Requirements for Installing JDK on Linux Platforms
See Oracle JDK Certified Systems Configurations for information about supported platforms, operating systems, and browsers.
Installing the JDK on Linux from Archive Files, Debian Packages, RPM Packages, and Oracle Linux Repositories
You can install the JDK on a Linux platform from archive files, debian packages, 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 Debian packages ( .deb ): This allows you to perform a system-wide JDK installation on Debian-based Linux platforms, and requires root access.
- 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.
JDK RPM packages for Generic Linux platforms and Oracle Linux platforms differ. The following table lists the differences:
Table 3-1 Difference between Generic Linux and OL platforms
JDK image is split into two packages: jdk- 21 -headless and jdk- 21 -headful .
- jdk- 21 -headless is a headless Java Runtime for running non-GUI applications.
- jdk- 21 -headful is headful Java Runtime and Development Tools for developing and running all types of applications.
jdk- 21 -headful package requires jdk- 21 -headless package. When these packages are installed together, they provide the same functionality as the jdk- 21 package for Generic Linux Platforms.
jdk- 21 -headless package registers java group with the alternatives framework.
jdk- 21 -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 21 release on a Linux platform:
| Download File | Instructions | Architecture (CPU Type) | Who Can Install |
|---|---|---|---|
| For Linux x64 systems: jdk- 21 .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- 21 .interim.update.patch_linux-aarch64.tar.gz | Installing the 64-Bit JDK on Linux Platforms | ARM — 64-bit | Anyone |
| For Linux x64 systems: jdk- 21 .interim.update.patch_linux-x64.deb | Installing the 64-Bit JDK Package on Debian-based Linux Platforms | Intel — 64-bit RPM-based Linux | Root |
| For Linux x64 systems: jdk- 21 .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- 21 .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.
To install the 64-bit JDK on a Linux platform:
- Download the required file:
- For Linux x64 systems: jdk- 21 .interim.update.patch_linux-x64_bin.tar.gz . For example jdk- 21 _linux-x64_bin.tar.gz
- For Linux aarch64 (64-bit ARM) systems: jdk- 21 .interim.update.patch_linux-aarch64_bin.tar.gz . For example, jdk- 21 _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- 21 _linux-x64_bin.tar.gz OR $ tar zxvf jdk- 21 _linux-aarch64_bin.tar.gz
The Java Development Kit files are installed in a directory named jdk- 21 .interim.update.patch .
Installing the 64-Bit JDK Package on Debian-based Linux Platforms
You can install the JDK Debian package for 64-bit Linux from the ( .deb ) file.
To install the 64-bit JDK Debian package on a Linux platform:
- Download the required file:
jdk- 21 .interim.update.patch_linux-x64_bin.deb . For example jdk- 21 _linux-x64_bin.deb
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.
$ sudo dpkg -i jdk- 21 _linux-x64_bin.deb
The Java Development Kit files are installed into /usr/lib/jvm/jdk-
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.
Ensure that you have the root user access. You can do this by running the command su and entering the superuser password.
To install the 64-bit JDK on an RPM-based Linux platform:
- Download the required file:
- For x64 systems: jdk- 21 .interim.update.patch_linux-x64_bin.rpm . For example, jdk- 21 _linux-x64_bin.rpm
- For aarch64 (64-bit ARM) systems: jdk- 21 .interim.update.patch_linux-aarch64_bin.rpm . For example, jdk- 21 _linux-aarch64_bin.rpm
Before you download a file, you must accept the license agreement.
$ sudo rpm -ivh jdk- 21 _linux-x64_bin.rpm OR $ sudo rpm -ivh jdk- 21 _linux-aarch64_bin.rpm
Upgrade the required package using the following command: $ sudo rpm -Uvh jdk- 21 _linux-x64_bin.rpm OR $ sudo rpm -Uvh jdk- 21 _linux-aarch64_bin.rpm
Note: JDK 21 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-
It is not required to reboot.
Installing the 64-Bit JDK on Oracle Linux Platforms
There are two OL-specific JDK RPM packages, jdk- 21 -headless and jdk- 21 -headful . When these packages are installed together, they provide full JDK functionality.
Install jdk- 21 -headless package if you only need headless Java Runtime for running non-GUI applications.
Install jdk- 21 -headful package if you need full JDK functionality for running any Java application and development.
The jdk- 21 -headful package depends on jdk- 21 -headless , hence installing jdk- 21 -headful package will result in the automatic installation of jdk- 21 -headless , if it is not installed yet.
To install the 64-bit JDK headless on an Oracle Linux platform use either dnf or yum command:
sudo dnf install jdk- 21 -headless
sudo yum install jdk- 21 -headless
To install the 64-bit JDK headful on an Oracle Linux platform use the following command:
sudo dnf install jdk- 21 -headful
sudo yum install jdk- 21 -headful