how to install java on ubuntu terminal easy apt for minecraft java


Java and the JVM (Java’s virtual machine) are required for many kinds of software, including Tomcat, Jetty, Glassfish, Cassandra and Jenkins.

In this guide, you will install various versions of the Java Runtime Environment (JRE) and the Java Developer Kit (JDK) using apt. You’ll install OpenJDK as well as the official JDK from Oracle. You’ll then select the version you wish to use for your projects. When you’re finished, you’ll be able to use the JDK to develop software or use the Java Runtime to run software.

Step 1 — Installing Java

An installation of Java comes with two main components. The JDK provides essential software tools to develop in Java, such as a compiler and debugger. The JRE is used to actually execute Java programs. Furthermore, there are two main installation options of Java to choose from. OpenJDK is the open-source implementation of Java and comes packaged with Ubuntu. Oracle JDK is the original version of Java and is fully maintained by Oracle, the developers of Java.

Both of these versions are officially recognized by Oracle. Both are also developed by Oracle, but OpenJDK has the addition of community contributions due to its open-source nature. However, starting with Java 11 the two options are now functionally identical as detailed by Oracle. The choice between which to install comes down to choosing the appropriate licensing for your circumstance. Additionally, OpenJDK has the option to install the JRE separately, while OracleJDK comes packaged with its JRE.

sudo apt update

check if java is installed

java -version


Command 'java' not found, but can be installed with:

sudo apt install default-jre              # version 2:1.11-72build1, or
sudo apt install openjdk-11-jre-headless  # version 11.0.14+9-0ubuntu2
sudo apt install openjdk-17-jre-headless  # version 17.0.2+8-1
sudo apt install openjdk-18-jre-headless  # version 18~36ea-1
sudo apt install openjdk-8-jre-headless   # version 8u312-b07-0ubuntu1

Execute the following command to install the JRE from OpenJDK 11:

java -version


openjdk version "11.0.18" *date here*
OpenJDK Runtime Environment (build 11.0.18+10-post-Ubuntu-0ubuntu122.10)
OpenJDK 64-Bit Server VM (build 11.0.18+10-post-Ubuntu-0ubuntu122.10, mixed mode, sharing)

You may need the JDK in addition to the JRE in order to compile and run some specific Java-based software. To install the JDK, execute the following command, which will also install the JRE:

javac -version


javac 11.0.18