Install Java on Linux
Created: November 20, 2018 by [lek-tin]
Last updated: November 20, 2018
Install manually
Step 1:
Download the source package from the oracle repository.
If your computer is 64-bit, download the x64
version; if it is 32-bit, download the x86
version.
Step 2:
Extract from the compressed file and move the package folder to /usr/java
. rememeber to run these commands as sudo
is not the root
user.
mv downloads-folder/jdk-<version>-linux-xxx.tar.gz /usr/java
tar -xvzf jdk-<version>-linux-xxx.tar.gz
rm jdk-<version>-linux-xxx.tar.gz
Step 3:
Add the java
path to the ~/.bashrc
file
vi ~/.bashrc
// Add the path to the java executable. Append following line to the bottom of the file
export PATH=$PATH:/usr/java/jdk<version>/bin
Step 4:
Reload bash with the changed settings like below
source ~/.bashrc // Long version
. ~/.bashrc // Short version
Alternatively, we can also open a new terminal window on which the changes we made will be applied.
Uninstallation
Java 11
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*