refresh java logo

How to check java installation and Java Version

Once you have installed java in your system, the next step is to check whether it has been installed properly or not. This tutorial explains the steps to check java installation in your system. It covers both the cases, first if Path variable for java is not set and second if Path variable for java is set after installation.

1. If Path variable is not set, to check if java is installed properly or not, open a command terminal like CMD, Secure Shell Client etc. and change or move to the java installation directory upto bin folder, now execute the command java -version. It will display the installed java version and other relevant information about java. Java compiler version can also be checked by executing javac -version command.

check java version

The image above shows the steps for checking java installation in Windows operating system using CMD terminal. Similarly for linux based operating system, execute the same command in any linux based terminal to check java installation.

2. If Path is set, no need to move to java installation directory, just execute the command java -version in any directory. It will display the installed java version and other relevant information about java. For compiler version execute javac -version command.

java version

If any of the above methods returns the version correctly, which means java is installed properly. Now you can start your first program in java.

If java is not installed, it will display an error message in Windows like "java is not recognized as internal or external command, operable program or batch file" after executing the command.

java not installed

What to do if I am getting error message like above "java is not recognized as .... " ?

This are two reasons of above error message, First java is not installed at all, you should install java and Second java is installed but Path variable is not set properly, you should set Path variable for java.

The following figure shows a typical structure of java installation directory in windows operating system. The installation directory could be different in different OS because it completely depends on OS and programmers selection as where to install java.

java installation directory
★★★
  • You must be in bin directory of jdk to check java installation if Path variable is not set.
  • You can execute java -help command on terminal to get different usage of java command.
  • Once you set the path of java, you need to restart the cmd(if already open) to get the correct result of java -version or javac -version command.