0 votes
1 view
in Java by (3.2k points)

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?

1 Answer

0 votes
by (33.8k points)

Follow these steps to install open JDK in Ubuntu (Linux):

  • Open Terminal from Application Dash or press Ctrl+Alt+T

First  Update the repository:

sudo add-apt-repository ppa: OpenJDK-r/ppa 

sudo apt update

  • Optional: If you want to seek accessible distributions of OpenJDK, use the following command:

apt search OpenJDK

  • Install the relevant version with the command below:

sudo apt install OpenJDK-8-JDK

sudo apt install OpenJDK-8-source #this is optional, the JDK source code

  • For JAVA_HOME (Environment Variable) write command as given below, in "Terminal" using your installation path...

export JAVA_HOME=/usr/lib/JVM/java-8-OpenJDK

(Note: /usr/lib/JVM/java-8-OpenJDK is symbolically practiced here just for presentation. You can use your path as per your installation.)

  • For PATH (Environment Variable) type command as explained below, in Terminal:

export PATH=$PATH:$JAVA_HOME/bin

  • To verify your installation:

java -version

...