How to Check Java Version?
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:
- Java Development Kit
- Java Runtime Environment
- 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.
- Command Prompt Method
- Contol Panel Method
- 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
- On the bottom left corner of the search bar type cmd.
- Open the command prompt
- 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.
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
- Search for Control Panel on the search bar present in the bottom left corner.
- Click on the Control Panel in the search panel to open.
- Go to Programs Directory
- Click on the Java icon to open Java Control Panel
- Click on the About button to know the version of java version installed on the machine.
Directories Method
- In this case go to settings.
- Click on apps and features.
- Search Java in the 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
- Click the Spotlight Search button in the top-right of the screen and search the terminal.
- Once the terminal is open type Java -version in the terminal.
Opening Control Panel and Looking for Java
- Open System Preference and click on the java icon.
- You will get a small window with the name Java Control Panel.
- Go to the Update and you will get the information regarding the installed version.
Directories Method
- To check the java version on macOS using the directories method press the command button+spacebar which will open popup boxes.
- This popup box will open a file that shows all the software installed in the MacOs along with their version as shown below:
Conclusion
- Java Development Kit consists of JRE and JVM. JDK can be installed on different OS.
- JDK comes with different versions and Java undergoes new releases after some development.
- We need to install a specific version of java to run some applications. And check the java version.
- 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.