Option 1:-
Running the following command in the command prompt will return the Java Version Installed, If Java is not installed then it would return “Unknown Command” error message.
For eg.
If it is installed then the above command would return
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) Client VM (build 25.66.-b18, mixed mode, sharing)
You may capture the output programmatically and then decide.
Option 2:-
You can also read the registry value to verify the Java installation
32 bit
"HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion"
64 bit
"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\JavaSoft\Java Runtime Environment\CurrentVersion"
Regards
Anser