Jdk version check linux

How to Check Java Version On Linux | Ubuntu/Debian/CentOS

Java is one of the most popular and widely used programming languages around the globe. If you are a Java developer then you must have a knowledge of “how to check java version”. There are several methods to check which Java version installed in your system.

If you don’t know how to install Java, you should read my guide on How to Install Java on Ubuntu 20.04.

In the post, we will show you how to check java version on CentOS, Ubuntu and Debian operating systems.

Prerequisites

  • A server running Debian 10.
  • A root password is set up in your server.

Check Java Version on Linux

If you want to check the Java version on Ubuntu, Debian or CentOS operating systems, open a command-line terminal and run the following command:

This will display the installed version of Java as shown below:

You can also check the Java compiler version using the javac command as shown below:

You should see the Java compiler version in the following output:

Check Java Version Using the Java Installation Path

You can also check the java version with the help of Java installation path. There is two way to find the Java installation directory or path.

The first method to find the Java installation path with the following command:

This will display the complete path of the Java as shown below:

Note: For CentOS and RHEL operating system, run the following command:

You can also use the whereis command to check the Java path.

Run the whereis command as shown below:

You should see the following output:

Next, run the ls command to list the content of /usr/bin/java:

You should see the following output:

In the above output, you should see that /usr/bin/java point to symbolic link /etc/alternatives/java.

Now, run the ls command again to list the content of /etc/alternatives/java.

This will display the complete path of the Java as shown below:

Check Java Version by Searching in Installed Package List

You can also check the Java version to list installed packages and search for Java. For Ubuntu and Debian operating systems, follow the below steps:

You can use either apt or dpkg command to list all installed packages.

List all installed packages and search for Java using the apt command:

You should see the installed version of Java in the following output:

Читайте также:  Как восстановить ионообменный картридж гейзер

List all installed packages and search for Java using the dpkg command:

You should see the installed version of Java in the following output:

For CentOS and RHEL operating systems, follow the below steps:

You can use yum or dnf command to list all installed packages and search for Java as shown below:

This will display the installed version of Java as shown below:

Conclusion

In the above guide, you learned a different method of how to check the Java version on Linux. You can now any of the above methods to check the Java version.

Источник

How to Check Java Version Installed on Linux

Home » SysAdmin » How to Check Java Version Installed on Linux

How do I check my current Java version? There are several ways to check if Java is installed and which version is running on your system.

In this tutorial, learn how to check the Java version installed on Linux distros, including Ubuntu, CentOS, and Debian.

  • A user account with sudo privileges
  • Access to the command-line/terminal window
  • A version of Java

Method 1: Check the Java Version On Linux

To check the Java version on Linux Ubuntu/Debian/CentOS:

1. Open a terminal window.

2. Run the following command:

3. The output should display the version of the Java package installed on your system. In the example below, OpenJDK version 11 is installed.

Note: If the output indicates there is no such package on the system, you can install it with the help of one of our guides – How to install Java on Ubuntu or How to Install Java on CentOS.

You can also check the version of the primary Java compiler – javac (pronounced “java-see”) with the command:

Method 2: Find Version by Checking Path Where Java is Installed

There are two ways to find the path of the Java directory.

The first option includes running a single command:

The system should respond with the path where Java is installed.

Note: This option may not work on CentOS systems. If you have issues finding the path of the Java directory with the command above, use the alternative outlined below.

Alternatively, you can use the whereis command and follow the symbolic links to find the Java path.

1. Run the command:

The output tells you that Java is located in /usr/bin/java.

2. List the content of the /usr/bin/java directory:

Inspecting the directory shows that /usr/bin/java is only a symbolic link for /etc/alternatives/java.

3. Just like in the previous step, list the content of the provided path by running:

Finally, the output displays /etc/alternatives/java is another symbolic link and that the real path of the Java directory is /usr/lib/jvm/java-11-openjdk-amd64/bin/java.

Method 3: Search for Java in the Installed Packages List

You can also prompt the system to list installed packages and search for Java, with its version number.

Find Java by listing all installed packages.

1. To generate a list of all installed packages, use the command:

2. Scroll up/down until you find the Java packages as shown in this example.

To avoid searching through all installed packages, list Java packages only. Prompt the system to list a specific software package. In this case, the package name is openjdk:

Читайте также:  Как посмотреть сколько отпечатал принтер hp laserjet

Note: CentOS users need to modify the commands for listing installed packages for their package manager. Use the commands: sudo yum list installed and sudo yum list installed | grep -i openjdk instead.

With this article, you have successfully checked the Java version installed on Linux. We also covered checking the Java path and searching for Java among the installed packages.

Once the Java version is confirmed, you can start developing anything from lightweight mobile to desktop applications.

Источник

How to check Java Version on Linux Ubuntu

It is practically a Turing-complete language so anything can be done on it. Most of the things one can do in Python can also be done in Java. Jpython is a Python version that runs on Java in the JVM (Java Virtual Machine). In this guide, we will dive into the procedure of looking up the Java version on Ubuntu Linux and install it if it is not already available.

Understanding the Java Version

The Java version is an indicator of the release of Java software currently under use by your OS.

It is highly recommended that the version be updated for better performance, stability, sophisticated features, and the latest security patches. This can go a long way and help you in preventing many unwanted issues and staying up to date.

Many websites, packages, or libraries require you to update to the latest Java version. So, it is preferred to stay one step ahead and have the latest release downloaded on your system. For instance, the latest Java version enables you to view 3D images along with other exciting features.

So, without further ado, let’s delve into the procedure of Java version verification and installation.

Checking Your Java Version

Start by checking your Java version. To do this, simply type the following in the terminal window.

This will give us the Java version that’s currently in use.

However, as evident from the picture above, Java isn’t installed on our system. But the terminal gives us options to install packages. Copying these commands and running them should get you the version installed directly via the terminal. All these versions are “headless”, meaning they don’t require a graphical user interface.

However, to download the latest release (16.02), you can use the browser method. Now, let’s go through the step-by-step process of installation.

Installing Java Using the Browser

Follow the steps to download Java.

Go to Google and search “download java JDK” and open the first link from the search results.

JDK is the “Java Development Kit” used to develop programs that run on Java. Alternatively, you can click on the link here to go directly to the page.

Under the “Java SE downloads”, go to “Java SE 16” as that is the latest version. The next step is to download JDK.

Scroll through the packages till you find the “Linux x64 Debian Package”. Download the file next to it. Ubuntu uses Debian packages to install programs, so you’ll see that the file has a .deb extension.

Once you are done with the download, open the folder where the downloaded package is located. Right-click anywhere in the window and select “Open in Terminal”.

Читайте также:  Linux add file to another file

Type the following command in the terminal to start unpacking the downloaded package.

You can replace the highlighted part of the command with the name of the package corresponding to the Java version you downloaded.

Having done that, you can type in the following command to confirm that Java is installed on your system.

With that out of the way, set your package as the alternative. To do that, use the following command:

Now, we can finally check and verify our version by typing the following:

To install the compiler, just use the same command as before, only this time replace “java” with “javac”.

To check the Javac version, type the following command:

Additionally, to set the java_home path, enter the following:

$ sudo update-a;ternatives —config java

$ sudo gedit / etc / environment

Once the text editor opens, paste the copied line and assign it to “JAVA_HOME” as demonstrated below.

Once this is done, clear the screen and type in the following commands to complete the process of Java home path configuration.

$ source / etc / environment

Some Important Commands

Given below are certain commands you can use to check your version alongside other important things.

(This command shows all the Java versions installed on your system.)

(Shows Java version you are using.)

(Shows version of Java you are currently using.)

(Shows the version of Java compiler.)

(To find the location of Java.)

Remove Java Versions

To remove Java from your system, you can type in the following command:

To remove the package:

Press “Y” followed by “ENTER” and the package will be uninstalled.

Should You Use JRE or JDK?

To run Java programs, you’ll need JRE (Java runtime environment). It is compatible with Windows, Linux, Mac, Solaris, and many more.

JDK (Java Development Kit) is used to develop Java applications. It is usually where most programmers start from. It depends on what you want to do.

When to Use JDK

  • You want to write Java programs. It comes with a compiler and Java application launcher.
  • Has access to the main Java libraries for coding via Java application launcher which opens JRE.

When to Use JRE

  • You have to use libraries and other files. It does not have compiler and error detection agents of its own.
  • When you have to use utility packages like math or data related sets and instructions.
  • To run applications running on Java.

Some Applications of Java

Java is mainly used in:

  • Building Android applications.
  • In developing web and cloud applications.
  • Software tools like Eclipse and Netbeans.
  • Chatbots.
  • Games.
  • Scientific and Enterprise applications

Conclusion

To stay up to date and get a hands-on experience of the latest packages and software, keeping our programs updated is a must. This check and balance can really help us a long way in keeping our system efficient, protected, and up to date.

About the author

Zeeman Memon

Hi there! I’m a Software Engineer who loves to write about tech. You can reach out to me on LinkedIn.

Источник

Поделиться с друзьями
КомпСовет
Adblock
detector