How to install the JDK on Ubuntu Linux
How to install
Open JDK (Java developement kit) in Ubuntu (Linux)?
Open Terminal from Application Dash or press Ctrl+Alt+T
sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earliersudo apt update
Optional: To search available distributions of
openjdk, use the following command:
apt search openjdk
Install the appropriate version with the following command:
sudo apt install openjdk-8-jdksudo apt install openjdk-8-source #this is optional, the jdk source code
JAVA_HOME(Environment Variable) type command as shown below, in "Terminal" using your installation path...
/usr/lib/jvm/java-8-openjdkis symbolically used here just for demostration. You should use your path as per your installation.)
PATH(Environment Variable) type command as shown below, in
To check your installation:
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.
As root, do;
cd /usr/localtar xzf <the file you just downloaded>
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_13export PATH=$PATH:$JAVA_HOME/bin
If it's an update, you may also want to remove the old java installation directory in
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.