How to Install Java on Ubuntu 18.04
- HolyHosting

- Oct 30
- 2 min read
How to Install Java on Ubuntu 18.04: A Complete Guide
This guide will walk you through installing Java on Ubuntu 18.04. Commands work on any private server or machine running Ubuntu 18.04 Bionic Beaver, 16.04, or other LTS versions. Java is available in three editions: Micro (ME), Enterprise (EE), and Standard (SE). This guide focuses on Java SE 11 (LTS).

Java is a leading programming language, designed to minimize dependencies and follow the “write once, run anywhere” principle. Compiled Java code can run on any Java-supported platform, from simple web apps to advanced software.
JDK or JRE?
Oracle JRE includes the JVM and essential libraries.
JDK is a superset of JRE, providing additional tools like javac, jdb, and javadoc.
If you don’t compile Java software, JRE is sufficient. You can upgrade later if needed.
Use sudo if you’re not root.
Install Java Using Ubuntu Default Packages
apt-get update && apt-get upgrade
apt-get install default-jre
apt-get install default-jdk
java -version
javac -version
Expected output:
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.6+10-post-Ubuntu-1ubuntu118.04.1, mixed mode, sharing)
Install Java via Oracle JDK
apt-get update && apt-get upgrade
apt-get install software-properties-common
add-apt-repository ppa:linuxuprising/java
apt-get update
apt update; apt-get install oracle-java17-installer
java -version
javac -version
Expected output:
java version "14" 2020-03-17
Java(TM) SE Runtime Environment (build 14+36-1461)
Java HotSpot(TM) 64-Bit Server VM (build 14+36-1461, mixed mode, sharing)
Manage Multiple Java Versions
update-alternatives --config java
update-alternatives --config javac
update-alternatives --config javadoc
update-alternatives --config jarsigner
Set JAVA_HOME
nano /etc/environment
Add:
JAVA_HOME="/usr/lib/jvm/java-14-oracle/bin/java"
Apply changes:
source /etc/environment
echo $JAVA_HOME
Conclusion
We hope this guide has been helpful! 🚀 Remember, don’t hesitate to ask questions on the HolyHosting Discord or contact our support team.
Follow us on Twitter @HolyHosting to stay up to date.

Stuffy @ HolyHosting


















