Open a command prompt:
Version: java -version
Location: where java (in Windows)
which java (in Unix, Linux, and Mac)
To set Java home in Windows:
Right click on My computer → Properties → Advanced system settings → Environment Variable → System Variable → New. Give the name as JAVA_HOME and the value as (e.g.) c:\programfiles\jdk
Select Path and click Edit, and keep it in the beginning as:
%JAVA_HOME%\bin;
...remaining settings goes here