Use this tutorial to Install Java 12 on Ubuntu 19.04, 18.04 LTS, 16.04 LTS and LinuxMint 18 using PPA. Follow the below steps to Install Java on Ubuntu command line.
To install Java LTS release on your system follow below links:
- Read this => Install Java 11 on Ubuntu 18.04 (Bionic)
- Read this => Install Java 11 on Ubuntu 16.04 (Xenial)
Step 1 – Install Java 12 on Ubuntu
You need to enable additional repository to your system to install Java 10 on Ubuntu VPS. After that install Oracle Java 10 on an Ubuntu system using apt-get. This repository contains a package named oracle-java12-installer, Which is not an actual Java package. Instead of that, this package contains a script to install Java on Ubuntu.
Run below commands to install Java 12 on Ubuntu and LinuxMint.
sudo add-apt-repository ppa:linuxuprising/java sudo apt-get update sudo apt-get install oracle-java12-installer
Step 2 – Verify Java Inatallation
The apt repository also provides package oracle-java12-set-default to set Java 10 as your default Java version. This package will be installed along with Java installation. To make sure run below command.
sudo apt-get installoracle-java12-set-default
After successfully installing Oracle Java 12 using the above steps, Let’s verify the installed version using the following command.
java -version java version "12.0.1" 2019-04-16 Java(TM) SE Runtime Environment (build 12.0.1+12) Java HotSpot(TM) 64-Bit Server VM (build 12.0.1+12, mixed mode, sharing)
Step 3 – Setup JAVA_HOME and JRE_HOME Variable
The installer script set the environment variable for you. You can find these variables in /etc/profile.d/jdk.sh script.
cat /etc/profile.d/jdk.sh export J2SDKDIR=/usr/lib/jvm/java-12-oracle export J2REDIR=/usr/lib/jvm/java-12-oracle export PATH=$PATH:/usr/lib/jvm/java-12-oracle/bin:/usr/lib/jvm/java-12-oracle/db/bin export JAVA_HOME=/usr/lib/jvm/java-12-oracle export DERBY_HOME=/usr/lib/jvm/java-12-oracle/db
All done, you have successfully installed Java 10 on a Linux system. You may also need to install Tomcat server to run your Java web application. Use our another tutorial to Install Tomcat 7 or Install Tomcat 8 or Install Tomcat 9 on Ubuntu, Debian, and LinuxMint systems.