How to Check Java Version?

Learn via video course
FREE
View all courses
Java Course - Mastering the Fundamentals
Java Course - Mastering the Fundamentals
by Tarun Luthra
1000
5
Start Learning
Java Course - Mastering the Fundamentals
Java Course - Mastering the Fundamentals
by Tarun Luthra
1000
5
Start Learning
Topics Covered

Java is one of the most widely used programming languages. To execute code in any programming language, we need to set up required environments like editors, software, and IDEs. JDK (Java Development Kit) is the complete environment required to run java codes on any operating system. Since the introduction of Java, there have been constant developments in its features and these new features have been released for users in form of different versions.

Java uses a specific format while releasing new versions. These versions help to understand which version we are using as some applications need a specific version of Java. As Java can be installed on different OS, there are different methods on how to check Java versions. Production-ready releases of Java are versioned in the following scheme:

MAJOR.MINOR.SECURITY

For example, in Java 11.0.8, 11 is a major version, 0 is a minor version, and 8 is a secure version.
MAJOR - Major releases are bringing new features and functions.
MINOR - Minor releases contain various bug fixes and compatibility improvements.
SECURITY - Security releases provide critical security fixes.

Components of Java Language

Java language has three main components that are:

  1. Java Development Kit
  2. Java Runtime Environment
  3. Java Virtual Machine

Java Development Kit

  • JDK is a software development kit required to develop applications in Java.
  • JDK consists of development tools like a compiler and debugger in addition to JRE.
  • It contains JVM, JRE, and additional development tools like a compiler, interpreter, debugger, and many more things required for application development.

Java Runtime Environment

  • Java Runtime Environment (JRE) is an open-source software distribution with a Java class library, specific tools, and a JVM.
  • It is the most common environment for devices running Java applications. JRE can be used when a user has to use Java applications but does not do development.
  • Java source code is compiled and translated into Java bytecode. If you want to get output from this bytecode, you need JRE.

Java Virtual Machine

  • JVM(Java Virtual Machine) is an abstract machine. It is a specification that provides a runtime environment in which java bytecode can be executed.
  • When we run any Java program, the Java compiler first compiles your Java code into bytecode. After compilation JVM translates bytecode into machine code, i.e. machine-level instructions.
  • Java is known as a platform-independent language because programs written in Java are executed by JVM and not by the physical machine.

Methods to Check Java Version in Different OS

Different OS needs to install different Java Development Kits. Java versions help us understand what are the features being used in the current version of Java. Java version history starts from the JDK Beta version which was the first release of Java in 1995. The latest version of java is Java SE 18.0. 2.1.

Let's check how to check the java version in Windows OS and how to check the java version on Mac OS. There are three standard methods to check the java version on different Operating systems.

  1. Command Prompt Method
  2. Contol Panel Method
  3. Directories method

How to Check Java Version on Windows

Here we will see how to check the Java version on Windows Operating System using the three standard methods above.

Command Prompt Method

  1. On the bottom left corner of the search bar type cmd.

searching-cmd-on-windows

  1. Open the command prompt
  2. Once the command prompt is open type Java -version and hit enter. In the output, you will get the java version i.e installed on windows.

checking-java-version-on-windows

As we can see in the above image "1.8.0_21" is the current java version installed in the Windows OS.

Opening Control Panel and Looking for Java

  1. Search for Control Panel on the search bar present in the bottom left corner.
  2. Click on the Control Panel in the search panel to open.
  3. Go to Programs Directory
  4. Click on the Java icon to open Java Control Panel
  5. Click on the About button to know the version of java version installed on the machine.

looking-java-in-control-panel-windows

Directories Method

  1. In this case go to settings.

windows-setting

  1. Click on apps and features.

selecting-apps-and-features-options

  1. Search Java in the search bar.

searching-java-in-search-bar

As we can see in the image java version in "8.0.1440.1"

How to Check Java Version on Mac

Here we will see how to check the Java version on Windows Operating System using the three standard methods above.

Command Prompt Method

  1. Click the Spotlight Search button in the top-right of the screen and search the terminal.

spotlight-search-button

  1. Once the terminal is open type Java -version in the terminal.

checking-java-version-on-mac

Opening Control Panel and Looking for Java

  1. Open System Preference and click on the java icon.

open-system-preference

  1. You will get a small window with the name Java Control Panel.

selecting-java-from-system-preference

  1. Go to the Update and you will get the information regarding the installed version.

java-version-installed-info

Directories Method

  1. To check the java version on macOS using the directories method press the command button+spacebar which will open popup boxes.
  2. This popup box will open a file that shows all the software installed in the MacOs along with their version as shown below:

checking-version-history

Conclusion

  1. Java Development Kit consists of JRE and JVM. JDK can be installed on different OS.
  2. JDK comes with different versions and Java undergoes new releases after some development.
  3. We need to install a specific version of java to run some applications. And check the java version.
  4. In this article we have different methods on how to check the java version on Windows OS and how to check the java version on Mac OS.