snippetjavaCritical
How to install the JDK on Ubuntu Linux
Viewed 0 times
howinstalllinuxtheubuntujdk
Problem
Note: This is an old question and the answers reflect the world as it was then. Modern Ubuntu distributions have OpenJDK available which can be installed with
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?
sudo apt install default-jdkI 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?
Solution
Referring to Ask Ubuntu question How to set JAVA_HOME for OpenJDK?,
How to install
-
Open Terminal from Application Dash or press Ctrl+Alt+T
-
Update repository:
-
Optional: To search available distributions of
-
Install the appropriate version with the following command:
-
For
(Note:
-
For
-
To check your installation:
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-
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-jdk
sudo apt install openjdk-8-source #this is optional, the jdk source code-
For
JAVA_HOME (Environment Variable) type command as shown 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 used here just for demostration. You should use your path as per your installation.)-
For
PATH (Environment Variable) type command as shown below, in Terminal:export PATH=$PATH:$JAVA_HOME/bin-
To check your installation:
java -versionCode Snippets
sudo add-apt-repository ppa:openjdk-r/ppa # only Ubuntu 17.4 and earlier
sudo apt updateapt search openjdksudo apt install openjdk-8-jdk
sudo apt install openjdk-8-source #this is optional, the jdk source codeexport JAVA_HOME=/usr/lib/jvm/java-8-openjdkContext
Stack Overflow Q#14788345, score: 858
Revisions (0)
No revisions yet.