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
-
7Go to command prompt and simply type "java" and press Enter ;) – Nir Alfasi Sep 19 '13 at 07:06
-
1this has a problem, if java is installed but not set in path, this might give you misleading results – dharam Sep 19 '13 at 18:12
-
"I want to check it by java program" So you don't want to check just that java is installed, but also the correct version? Like from a bootstrap? – killjoy Aug 13 '18 at 16:12
-
You will be able to see a screen like, [enter image description here](https://i.stack.imgur.com/fMToI.png) – Imrankhan May 29 '19 at 17:02
12 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

- 61,933
- 36
- 195
- 321

- 13,738
- 20
- 78
- 116
-
This doesn't really answer the question - "I want to check it by java program not by cmd command". A good answer to this question is below by A4L (https://stackoverflow.com/a/18888451/100465). – Zach Alberico Aug 20 '19 at 17:52
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.

- 17,353
- 6
- 49
- 70
-
1This is the correct answer if you want to do it using java, like it says in the question. – killjoy Aug 13 '18 at 15:54
Open Command Prompt and type in the following command: java -version
Upon successful execution, the command will output the version of Java along with Java SE Runtime Environment’s build and Java HotSpot Client VM’s build.

- 6,409
- 4
- 33
- 46
-
This doesn't really answer the question - "I want to check it by java program not by cmd command" – Zach Alberico Aug 20 '19 at 17:53
-
1@ZachAlberico, Yes, but the question was answered before it was edited by the OP. – M. Abbas Aug 21 '19 at 18:22
-
command prompt:
C:\Users\admin>java -version (Press Enter>
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

- 7,512
- 7
- 39
- 72
Go to this link and wait for a while to load.
http://www.java.com/en/download/testjava.jsp
You will see the below image:
You can alternatively open command window and type java -version

- 7,882
- 15
- 65
- 93
-
7This solution would only work if you have the Java browser plugin installed and enabled, which really you shouldn't. Some modern browsers don't support or won't allow the Java plugin to run. For instance Google Chrome has no support for Java plugin – HairOfTheDog Oct 19 '15 at 23:23
-
MOST modern browsers do not support the NPAPI anymore. The latest version of firefox that supports Java is Firefox-ESR 51 – killjoy Aug 13 '18 at 15:53
-
This doesn't really answer the question - "I want to check it by java program not by cmd command" – Zach Alberico Aug 20 '19 at 17:52
After installing Java, set the path in environmental variables and then open the command prompt and type java -version
. If installed properly, it'll list the java version, jre version, etc.
You can additionally check by trying the javac
command too. If it displays some data, you've your java installed with the proper path set, else it'll that javac
is an invalid command.

- 44,383
- 11
- 84
- 103
-
-
This doesn't really answer the question - "I want to check it by java program not by cmd command" – Zach Alberico Aug 20 '19 at 17:53
-
@ZachAlberico The question was edited after the answer was posted. Is that the reason for your downvote? – Rahul Aug 22 '19 at 18:33
Type in the command window
java -version
If it gives an output everything should be fine. If you want to develop software you might want to set the PATH.

- 4,977
- 3
- 34
- 53
-
This doesn't really answer the question - "I want to check it by java program not by cmd command" – Zach Alberico Aug 20 '19 at 17:53
Check the installation directories (typically C:\Program Files (x86)
or C:\Program Files
) for the java folder. If it contains the JRE you have java installed.

- 1,905
- 1
- 19
- 18
type java -version in command prompt, it will give you the installed version of java on your system.

- 17
- 1
-
This doesn't really answer the question - "I want to check it by java program not by cmd command" – Zach Alberico Aug 20 '19 at 17:54
1)Open the command prompt or terminal based on your OS.
2)Then type java --version
in the terminal.
3) If java is installed successfullly it will show the respective version .
-
1This answer was already posted some times. Anything new you want to add? – Nico Haase Jun 24 '18 at 10:33
-
This doesn't really answer the question - "I want to check it by java program not by cmd command" – Zach Alberico Aug 20 '19 at 17:54
Using Apache Commons-Lang's SystemUtils.isJavaVersionAtLeast(JavaVersion)
import org.apache.commons.lang3.JavaVersion;
import org.apache.commons.lang3.SystemUtils;
if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)
System.out.println("Java version was 8 or greater!");

- 3,665
- 1
- 19
- 16
If java not installed yet. Then program written by java cannot be run to check if java is installed or not.

- 21
- 1