Javatpoint Logo
Javatpoint Logo

How to Check JDK Version in Linux?

This article will guide you in checking the JDK version installed in a computer system with Linux Operating System. Before diving into the main topic let us understand what is JDK.

What is JDK?

JDK stands for Java Development Kit, which is a software development kit used to develop Java applications. It is a collection of tools and utilities that allow developers to create, test, and deploy Java applications on various platforms, including Linux.

The Java Runtime Environment (JRE), which is contained in the JDK, is in charge of running Java programs. In addition to the JRE, the JDK also includes several development tools, such as a compiler, a debugger, and an application server, which is used to create Java applications.

Platform independence of the Java programming language allows Java code to run on any system with the Java Virtual Machine (JVM) installed. The JVM is responsible for interpreting Java bytecode and executing Java programs. The JDK includes a JVM, which is used to run Java programs during development and testing.

The JDK is typically installed on Linux systems using a package manager like apt-get or yum. Once it has been set up, the JDK can be used from the command line or from an IDE like Eclipse or IntelliJ IDEA.

The JDK is essential for Java developers because it provides everything, they need to create Java applications from scratch. Java is widely used in many industries, including banking, e-commerce, and telecommunications, to develop complex enterprise applications. The JDK's rich set of features, such as cross-platform compatibility, object-oriented programming, and automatic memory management, make Java a popular choice for developing mission-critical applications.

In addition to the JDK, Linux also supports OpenJDK, which is an open-source implementation of the Java SE platform. OpenJDK is available in most Linux distributions and provides an alternative to the proprietary Oracle JDK. OpenJDK is widely used in Linux-based environments, including web servers, mobile devices, and embedded systems.

Steps for Checking JDK version in Linux

Checking the JDK version in Linux is a simple process that can be done using the command line. Here is how to check the JDK version in Linux:

Step 1: Open a Terminal Window

To check the JDK version in Linux, the first step is to open a terminal window. You may launch the terminal in the majority of Linux distributions by hitting Ctrl+Alt+T or by looking for "Terminal" in the programme menu.

Step 2: Run the Java -version Command

Activate the Java -version Command. The Java -version command can be used to determine the JDK version once the terminal window has been opened. The Java Runtime Environment (JRE) version that is currently installed on your machine is shown by this command.

If Java is not installed on your system, you will see an error message indicating that the command is not found.

Step 3: Interpret the Output

After running the java -version command, you will see an output similar to the following:

The first line of the output shows the version of the JDK installed on your system. The version in this case is 1.8.0 282.

he JDK's build number is displayed on the second line of the report. The build number in this instance is b08

The Java Virtual Machine (JVM) version that is installed on your system is displayed in the third line of the report. Version in this case is 25.282-b08.

How to Check JDK Version in Linux

Step 4: Check the Path

If you have multiple JDK versions installed on your system, you can use the which command to check the path to the java executable file for each version. Type the following command and press Enter:

This command displays the path to the java executable file that is being used by the system.

Step 5: Check the Alternatives

In some Linux distributions, you can use the update-alternatives command to switch between different JDK versions. To see a list of installed JDK versions and their paths, type the following command and press Enter:

This command displays a list of installed JDK versions and their paths. You can then select the JDK version you want to use by typing the number next to it and pressing Enter.

In Conclusion, Checking the JDK version in Linux is a straightforward process that can be done using the command line. By running the java -version command, you can see the version of the JDK installed on your system. If you have multiple JDK versions installed on your system, you can use the which command to check the path to the java executable file for each version, and the update-alternatives command to switch between different versions. Knowing the JDK version installed on your system can help you troubleshoot Java-related issues and ensure that you have the latest security updates installed. Hope you understood this topic.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA