top ad article

Java is one of the most popular and widely used programming languages in the world. Java initial development dates back to 1995. It has seen huge adoption in the development of modern applications which include Desktop applications, Android applications and Web applications. You can install and run Java on many operating systems, among them Windows, Linux, macOS, Raspberry Pi, and many BSD based systems.

Java new features and concepts can be adopted to solve a variety of modern-day engineering problems. In this article we walk you through the installation of Java / OpenJDK on MX Linux 19.

Install Java / OpenJDK on MX Linux 19

The two standard installations of Java on MX Linux:

  • Oracle Java – May require commercial license for support
  • OpenJDK – Free and open-source implementation of the Java Platform, Standard Edition.

Install Java / OpenJDK on MX Linux 19

OpenJDK is an open source implementation of the Java Standard Edition platform. The OpenJDK packages are available on MX Linux 19 system repositories.

Update APT package index using the command:

$ sudo apt update

You can search for packages matching openjdk:

$ apt-cache search openjdk

Here is my search results:

libhsdis0-fcml - HotSpot disassembler plugin using FCML
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)
jtreg - Regression Test Harness for the OpenJDK platform
libreoffice - office productivity suite (metapackage)
openjdk-11-dbg - Java runtime based on OpenJDK (debugging symbols)
openjdk-11-demo - Java runtime based on OpenJDK (demos and examples)
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-jre-zero - Alternative JVM for OpenJDK, using Zero
openjdk-11-source - OpenJDK Development Kit (JDK) source files
openjdk-11-jre-dcevm - Alternative VM for OpenJDK 11 with enhanced class redefinition
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
nvidia-openjdk-8-jre - NVIDIA provided OpenJDK Java runtime, using Hotspot JIT
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

To install the latest release of OpenJDK on MX Linux 19 run the command below.

sudo apt install default-jdk

You’ll be asked to confirm installation of OpenJDK on MX Linux.

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  default-jdk-headless openjdk-11-jdk openjdk-11-jdk-headless
Suggested packages:
  openjdk-11-demo openjdk-11-source visualvm
Recommended packages:
  libxt-dev
The following NEW packages will be installed:
  default-jdk default-jdk-headless openjdk-11-jdk openjdk-11-jdk-headless
0 upgraded, 4 newly installed, 0 to remove and 34 not upgraded.
Need to get 229 MB of archives.
After this operation, 239 MB of additional disk space will be used.
Do you want to continue? [Y/n] y

Installation time is relative to your internet speed.

To install an exact version of OpenJDK use the command syntax:

sudo apt install openjdk-<version>-jdk

Examples:

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

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

Confirm successful Java installation on MX Linux by checking the version.

$ java  --version
openjdk 11.0.9.1 2020-11-04
OpenJDK Runtime Environment (build 11.0.9.1+1-post-Debian-1deb10u2)
OpenJDK 64-Bit Server VM (build 11.0.9.1+1-post-Debian-1deb10u2, mixed mode, sharing)

Selecting default Java Version on MX Linux 19

When running more than one version of Java on the same system, you can use update-java-alternatives command to set default version.

To list installed versions of Java run:

$ update-java-alternatives --list
java-1.11.0-openjdk-amd64      1111       /usr/lib/jvm/java-1.11.0-openjdk-amd64
java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64

To set the default version use the command below.

$ sudo update-alternatives --config java

Choose the version to set.

$ sudo update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

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

Confirm the new default Java version:

$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~mx19+1-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Now Java has been installed on MX Linux 19 and is ready for use. You’re on a roll to host Java Applications or begin Development of powerful applications.

Other guides around MX Linux:

Install Visual Studio Code (VSCode) on MX Linux

How To Install Brave Browser on MX Linux

How To Install Google Chrome on MX Linux

Previous articleEasily Create and Pin groups to Taskbar on Windows 10
Next articleLinux Commands To Check System information

LEAVE A REPLY

Please enter your comment!
Please enter your name here