JDK and/or JRE releases for OpenJDK or Oracle can be installed using the package manager on most mainstream Linux distribution. (The choices that are available to you will depend on the distro.)
As a general rule, the procedure is to open terminal window and run the commands shown below. (It is assumed that you have sufficient access to run commands as the "root" user ... which is what the
sudo command does. If you do not, then please talk to your system's administrators.)
Using the package manager is recommended because it (generally) makes it easier to keep your Java installation up to date.
apt-get, Debian based Linux distributions (Ubuntu, etc)
The following instructions will install Oracle Java 8:
$ sudo add-apt-repository ppa:webupd8team/java $ sudo apt-get update $ sudo apt-get install oracle-java8-installer
Note: To automatically set up the Java 8 environment variables, you can install the following package:
$ sudo apt-get install oracle-java8-set-default
If you prefer to create the
.deb file yourself from the
.tar.gz file downloaded from Oracle, do the following (assuming you've downloaded the
$ sudo apt-get install java-package # might not be available in default repos $ make-jpkg ./<jdk>.tar.gz # should not be run as root $ sudo dpkg -i *j2sdk*.deb
Note: This expects the input to be provided as a ".tar.gz" file.
slackpkg, Slackware based Linux distributions
sudo slapt-get install default-jdk
yum, RedHat, CentOS, etc
sudo yum install java-1.8.0-openjdk-devel.x86_64
On recent Fedora releases,
yum has been superseded by
sudo dnf install java-1.8.0-openjdk-devel.x86_64
In recent Fedora releases, there are no packages for installing Java 7 and earlier.
pacman, Arch based Linux distributions
sudo pacman -S jdk8-openjdk
sudo is not required if you're running as the root user.
The Gentoo Java guide is maintained by the Gentoo Java team and keeps an updated wiki page including the correct portage packages and USE flags needed.
Installing Oracle JDKs on Redhat, CentOS, Fedora
Installing JDK from an Oracle JDK or JRE
Download the appropriate Oracle archive ("tar.gz") file for the desired release from the Oracle Java downloads site.
Change directory to the place where you want to put the installation;
Decompress the archive file; e.g.
tar xzvf jdk-8u67-linux-x64.tar.gz
Retrieve the required RPM file for the desired release from the Oracle Java downloads site.
Install using the
rpm command. For example:
$ sudo rpm -ivh jdk-8u67-linux-x644.rpm