How can I install Java / OpenJDK on Linux Mint 20?. Java is a popular open source programming language, created in 1995 and has been used extensively for development of Desktop Applications, Android apps, Web & Application servers, Games and many web applications handling real-time transactions. Java can be used on different platforms such as Linux, macOS, Windows, Raspberry Pi, and many others.

Java is created to be secure, fast and powerful with huge community support which means you can’t find any implementation logic missing in Java. Java is an object oriented language which gives a clear structure to programs and allows code to be reused, lowering development costs. This tutorial will help you in the steps of installing Java on Linux Mint 20.

Install Java / OpenJDK on Linux Mint 20

There are two main implementations of Java.

  • Oracle Java – This requires a commercial license as it targets enterprise customers who values stability and Long term support.
  • OpenJDK – This is a free and open-source implementation of the Java Platform, Standard Edition.

Install OpenJDK on Linux Mint 20

OpenJDK is an open source implementation of the Java Standard Edition platform. The contributors are from Oracle and the huge Java community. To install OpenJDK on Linux Mint 20 there is no pre-requisite as the packages are directly available in the OS repositories.

This is how you can list all available versions of OpenJDK on Linux Mint.

$ sudo apt update
$ apt-cache search openjdk

Sample list:

default-jdk - Standard Java or Java compatible Development Kit
default-jdk-doc - Standard Java or Java compatible Development Kit (documentation)
default-jdk-headless - Standard Java or Java compatible Development Kit (headless)
default-jre - Standard Java or Java compatible Runtime
default-jre-headless - Standard Java or Java compatible Runtime (headless)
openjdk-11-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-11-doc - OpenJDK Development Kit (JDK) documentation
openjdk-11-jdk - OpenJDK Development Kit (JDK)
openjdk-11-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-11-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-11-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-11-source - OpenJDK Development Kit (JDK) source files
crypto-policies - unify the crypto policies used by different applications and libraries
jtreg - Regression Test Harness for the OpenJDK platform
libhsdis0-fcml - HotSpot disassembler plugin using FCML
libjax-maven-plugin - Using the xjc goal with OpenJDK 11+
libreoffice - office productivity suite (metapackage)
openjdk-11-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-11-jre-dcevm - Alternative VM for OpenJDK 11 with enhanced class redefinition
openjdk-11-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-8-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-8-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-8-doc - OpenJDK Development Kit (JDK) documentation
openjdk-8-jdk - OpenJDK Development Kit (JDK)
openjdk-8-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-8-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-8-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-8-jre-zero - Alternative JVM for OpenJDK, using Zero/Shark
openjdk-8-source - OpenJDK Development Kit (JDK) source files
uwsgi-app-integration-plugins - plugins for integration of uWSGI and application
uwsgi-plugin-jvm-openjdk-11 - Java plugin for uWSGI (OpenJDK 11)
uwsgi-plugin-jwsgi-openjdk-11 - JWSGI plugin for uWSGI (OpenJDK 11)
uwsgi-plugin-ring-openjdk-11 - Closure/Ring plugin for uWSGI (OpenJDK 11)
uwsgi-plugin-servlet-openjdk-11 - JWSGI plugin for uWSGI (OpenJDK 11)
java-package - Utility for creating Java Debian packages
openjdk-13-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-13-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-13-doc - OpenJDK Development Kit (JDK) documentation
openjdk-13-jdk - OpenJDK Development Kit (JDK)
openjdk-13-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-13-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-13-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-13-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-13-source - OpenJDK Development Kit (JDK) source files
openjdk-14-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-14-demo - Java runtime based on OpenJDK (demos and examples)
openjdk-14-doc - OpenJDK Development Kit (JDK) documentation
openjdk-14-jdk - OpenJDK Development Kit (JDK)
openjdk-14-jdk-headless - OpenJDK Development Kit (JDK) (headless)
openjdk-14-jre - OpenJDK Java runtime, using Hotspot JIT
openjdk-14-jre-headless - OpenJDK Java runtime, using Hotspot JIT (headless)
openjdk-14-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-14-source - OpenJDK Development Kit (JDK) source files

To install the distribution default OpenJDK version use the following commands.

sudo apt install default-jdk

Accept installation prompt by hitting the y key in your keyboard:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  default-jdk-headless libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk
  openjdk-11-jdk-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev
Suggested packages:
  libice-doc libsm-doc libx11-doc libxcb-doc libxt-doc openjdk-11-demo openjdk-11-source visualvm
The following NEW packages will be installed:
  default-jdk default-jdk-headless libice-dev libpthread-stubs0-dev libsm-dev libx11-dev libxau-dev libxcb1-dev libxdmcp-dev libxt-dev openjdk-11-jdk
  openjdk-11-jdk-headless x11proto-core-dev x11proto-dev xorg-sgml-doctools xtrans-dev
0 upgraded, 16 newly installed, 0 to remove and 58 not upgraded.
Need to get 224 MB of archives.
After this operation, 240 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
...

Installation time is relative to your internet speed.

You can as well select a specific version by passing the version number to the package name.

sudo apt install openjdk-<version>-jdk

Examples:

--- Install OpenJDK 14 ---
$ sudo apt install openjdk-14-jdk

--- Install OpenJDK 13 ---
$ sudo apt install openjdk-13-jdk

--- Install OpenJDK 11 ---
$ sudo apt install openjdk-11-jdk

--- Install OpenJDK 8 ---
$ sudo apt install openjdk-8-jdk

Confirm the version of Java installed on Linux Mint 20.

$ java  --version
openjdk 11.0.7 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)

Selecting default Java Version on Linux Mint 20

If you installed more than one version of Java in Linux Mint 20 there is a command that can be used to change Java version at runtime.

Get the list of Java versions installed.

$ update-java-alternatives --list
java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.13.0-openjdk-amd64      1311       /usr/lib/jvm/java-1.13.0-openjdk-amd64
java-1.14.0-openjdk-amd64      1411       /usr/lib/jvm/java-1.14.0-openjdk-amd64

To set the default version use the command below.

$ sudo update-alternatives --config java

In my example I’m switching to Java 13:

$ sudo update-alternatives --config java
[sudo] password for computingforgeeks:         
There are 3 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                         Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-14-openjdk-amd64/bin/java   1411      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java   1111      manual mode
  2            /usr/lib/jvm/java-13-openjdk-amd64/bin/java   1311      manual mode
  3            /usr/lib/jvm/java-14-openjdk-amd64/bin/java   1411      manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-13-openjdk-amd64/bin/java to provide /usr/bin/java (java) in manual mode

Confirm the new default Java version:

$ java --version
openjdk 13.0.3 2020-04-14
OpenJDK Runtime Environment (build 13.0.3+3-Ubuntu-1ubuntu2)
OpenJDK 64-Bit Server VM (build 13.0.3+3-Ubuntu-1ubuntu2, mixed mode)

That is how you can easily install multiple versions of Java on Linux Mint 20 and switch from one version to another.

More guides on Linux Mint.

Install Visual Studio Code (VSCode) on Linux Mint

How To Install KDE Plasma Desktop on Linux Mint

LEAVE A REPLY

Please enter your comment!
Please enter your name here

4 × three =