Do you need Java? So you can install it Java on Linux

Do you need Java? So you can install it on Linux

Java is an element that, surely, more than once we have needed to start up on our computer. In Windows, we only have to go to the website of this environment, download the installer and install it in the operating system as one more program. Also, many programs that depend on it (such as JDownloader) usually have it included so that we don’t have to do anything. But what about Linux? Java is also available for this OS, as expected. Although it is true that, to start it up, we may have to take a few laps. Let’s see how it’s done.

Main features of Java

Java is a programming language that sought to offer something different from what all other languages ​​offer. While most of these depend directly on the operating system where we run it, and often require compiling it to work on them, Java has its own virtual machine that allows the same program, compiled on any system, to work equally well on all systems. operating systems.

Beyond that, what are the main features of this language?

  • Multi platform. It is a language that we can run almost on any operating system without changes.
  • Easy. A system derived from C and C++, but designed with simplicity in mind and without unnecessary elements.
  • Object-oriented programming language. It allows you to design software in a very simple and efficient way.
  • Optimized and secure. Thanks to its features, such as garbage collection, we avoid memory overload and possible data leaks.
  • Multi thread. It allows to execute several tasks at the same time within a program.
  • It allows including sounds and other multimedia elements, as well as databases, within the programs.

Next, we are going to see how to install the complex package, the JDK, on ​​any Linux distribution in several different ways.

Install OpenJDK and Linux

Although we can find the original Java to install in any Linux distribution, we are going to talk about OpenJDK. What is this? Broadly speaking, it is a free version of the Java JDK . This offers developers and users everything they may need from Java itself, while staying true to the “Linux philosophy” so characteristic of these systems.

To install it, the first thing we must do is update the list of repositories by executing the following command in a terminal: sudo apt update

Once this command has been executed, the next step will be to see a list with all the packages that we can install from this OpenJDK. To do this, we will execute the following command: apt list OpenJDK*

As we can see, there are packages for all kinds of architectures, java versions, demos, development options, etc. In addition, we can also install a global OpenJDK, valid for all versions, and we can even choose if we want to install only the JRE, in case we don’t plan to program and just want to run programs.

We can install the standard version of OpenJDK, for a 64-bit system, with the following command: sudo apt install -a=amd64 openjdk-11-jdk

The “apt” package manager is the most widely used within Linux ecosystems. Distros like Ubuntu, Debian or Mint, to name a few examples, use it. But, in case of using other distros, with other package managers, we can also install OpenJDK with the corresponding command:

On distros like Fedora: sudo dnf install java-11-openjdk-devel.x86_64

En Arch Linux: sudo pacman -S jdk-openjdk

When the installation is finished, we will already have Java installed on our Linux. Having installed OpenJDK, we will have everything we need to create, compile, test and run all kinds of programs created in this programming language. If, on the contrary, instead of the JDK we have installed the JRE, we will only be able to execute the programs, but not create them.

Check the version of Java installed

To check that everything is correctly installed on our Linux, we can resort to a very simple command that will tell us the version of Java that we have installed on the PC. To do this, we simply have to execute the following command in a terminal console: java -version

When doing so, the version of Java (or OpenJDK, in our case) that we have on the PC will appear. If this appears, it means that this environment has been correctly installed on the computer, and it is ready for us to start working with it. If it does not appear, then we do not have Java installed on the computer, and we will have to reinstall it.

Uninstall OpenJDK

If we no longer need to use Java on Linux, we can uninstall it to have our system clean, optimized and free of junk. To do this, what we must do is open a terminal console and execute the following command in it: sudo apt purge --auto-remove openjdk*

By having an asterisk to the right of openjdk, we are indicating to the command that what we want is to delete all the packages that correspond to openjdk, thus deleting all the versions that we may have installed at once. Also, if we are advanced users and only want to remove a specific package, we can remove specific parts by changing “openjdk*” to the specific name of the package we want to remove.

Once the deletion of the data is finished, we can verify that it has been deleted correctly by executing the command that we already saw in the previous step: java -version

This will return a message indicating that we do not have any Java components installed.

1 Trackback / Pingback

  1. How to Install Apache Tomcat 10 on Ubuntu 22.04 with Nginx - LinuxStoney

Leave a Reply

Your email address will not be published.


*