Table of contents
1.
Introduction
2.
Components of Java Language
2.1.
Java Development Kit (JDK)
2.2.
Java Runtime Environment (JRE)
2.3.
Java Virtual Machine (JVM)
3.
Methods to Check Java Version in Different OS:
3.1.
How to Check Java Version on Windows
3.2.
How to Check Java Version on Mac
3.3.
Example output of java -version command:
4.
Frequently Asked Questions
4.1.
How can I verify if Java is installed on my system?
4.2.
What is the difference between JDK and JRE?
4.3.
Is it necessary to update Java regularly?
5.
Conclusion 
Last Updated: Jun 19, 2024
Easy

How to Check Java Version?

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Java is a popular programming language used to create applications for various platforms. It is important to know the version of Java installed on your system to ensure compatibility with the programs you develop. 

How to Check Java Version?

In this article, we will learn about the components of the Java language & learn how to check the Java version on different operating systems like Windows & Mac.

Components of Java Language

The Java language consists of several key components that work together to enable the development & execution of Java programs. These components include:

Java Development Kit (JDK)

The JDK is a software development kit that provides the necessary tools & libraries for developing Java applications. It includes the Java compiler (javac), which converts Java source code into bytecode, & other utilities like the Java debugger & documentation generator.

Java Runtime Environment (JRE)

The JRE is a runtime environment that provides the necessary components to run Java applications. It includes the Java Virtual Machine (JVM) & the core libraries required by Java programs. The JRE is typically installed on end-user systems to execute Java applications.

Java Virtual Machine (JVM)

The JVM is an abstract machine that provides a runtime environment for executing Java bytecode. It interprets the bytecode & translates it into machine-specific instructions, allowing Java programs to run on different platforms without modification. The JVM also handles memory management, security, & other runtime tasks.

Methods to Check Java Version in Different OS:

Checking the Java version is a simple process that can be done using the command line interface on different operating systems. Here are the methods to check the Java version on Windows & Mac:

How to Check Java Version on Windows

Open the Command Prompt by pressing the Windows key + R, typing "cmd," & pressing Enter.

In the Command Prompt, type the following command & press Enter:

-version


The Java version installed on your Windows system will be displayed in the output. It will show the version number, build number, & other details.

How to Check Java Version on Mac


Open the Terminal application on your Mac. You can find it in the Applications > Utilities folder or by using Spotlight search.

In the Terminal, type the following command & press Enter

-version


The Java version installed on your Mac will be displayed in the output, similar to the Windows example.

Example output of java -version command:

version "1.8.0_301"


Java(TM) SE Runtime Environment (build 1.8.0_301-b09)

Java HotSpot(TM) 64-Bit Server VM (build 25.301-b09, mixed mode)

The output indicates that Java version 1.8.0_301 is installed on the system.

Frequently Asked Questions

How can I verify if Java is installed on my system?

Open your command prompt or terminal and type java -version. If Java is installed, it will display the installed version.

What is the difference between JDK and JRE?

The JDK is a development kit for building Java applications, which includes the JRE for running them. The JRE is a subset of the JDK that provides the runtime environment only.

Is it necessary to update Java regularly?

Yes, regularly updating Java ensures that you have the latest security features and performance improvements. It is crucial for maintaining the security and efficiency of your applications.

Conclusion 

In this article, we have learned about the components of the Java language, including the Java Development Kit (JDK), Java Runtime Environment (JRE), & Java Virtual Machine (JVM). We also discussed the methods to check the Java version on different operating systems like Windows & Mac using the command line interface. 

You can refer to our guided paths on Code 360. You can check our course to learn more about DSADBMSCompetitive ProgrammingPythonJavaJavaScript, etc. Also, check out some of the Guided Paths on topics such as Data Structure andAlgorithmsCompetitive ProgrammingOperating SystemsComputer Networks, DBMSSystem Design, etc., as well as some Contests, Test Series, and Interview Experiences curated by top Industry.

Live masterclass