How to know the current version of Java


If you have java set in your System Environment Variable (PATH/JAVA_HOME) by using the Command Line (CMD on Windows or Terminal or Linux/Mac) you can simply know which version of Java is set in the PATH and is currently in use, simply use the command java -version

% java -version
openjdk version "1.8.0_332"
OpenJDK Runtime Environment Corretto-8.332.08.1 (build 1.8.0_332-b08)
OpenJDK 64-Bit Server VM Corretto-8.332.08.1 (build 25.332-b08, mixed mode)
Identify the current version of Java set in PATH

If you will use java -v you will get an error,

java -v
Unrecognized option: -v
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. The program will exit.

You can also know the version of Java Compiler utility using the command javac -version

% javac -version
javac 1.8.0_332
Know the version of Java Compiler

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap