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


Have Questions? Post them here!
Advertisements
Try Out Code2care Dev Tools:

Advertisements

Advertisements
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.