Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check whether java is installed on the computer

Tags:

java

runtime

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

like image 684
Sandeep Sehrawat Avatar asked Sep 19 '13 07:09

Sandeep Sehrawat


People also ask

How do I check if Java is enabled?

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.


2 Answers

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 
like image 62
SpringLearner Avatar answered Oct 14 '22 17:10

SpringLearner


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.

like image 38
A4L Avatar answered Oct 14 '22 16:10

A4L