I am trying to install java windows application on client machine.I want to check whether requried JRE is installed on the machine or not. I want to check it by java program not by cmd command
Click Tools > Add-ons. Click on the Plugins tab, then highlight Java Plug-in 2. If the button for the plug-in says Disable, Java is enabled.
if you are using windows or linux operating system then type in command prompt / terminal
java -version
If java is correctly installed then you will get something like this
java version "1.7.0_25" Java(TM) SE Runtime Environment (build 1.7.0_25-b15) Java HotSpot(TM) Client VM (build 23.25-b01, mixed mode, sharing)
Side note: After installation of Java on a windows operating system, the PATH variable is changed to add java.exe so you need to re-open cmd.exe to reload the PATH variable.
Edit:
CD to the path first...
cd C:\ProgramData\Oracle\Java\javapath java -version
You can do it programmatically by reading the java
system properties
@Test public void javaVersion() { System.out.println(System.getProperty("java.version")); System.out.println(System.getProperty("java.runtime.version")); System.out.println(System.getProperty("java.home")); System.out.println(System.getProperty("java.vendor")); System.out.println(System.getProperty("java.vendor.url")); System.out.println(System.getProperty("java.class.path")); }
This will output somthing like
1.7.0_17 1.7.0_17-b02 C:\workspaces\Oracle\jdk1.7\jre Oracle Corporation http://java.oracle.com/ C:\workspaces\Misc\Miscellaneous\bin; ...
The first line shows the version number. You can parse it an see whether it fits your minimun required java version or not. You can find a description for the naming convention here and more infos here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With