Reputation: 586
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
Upvotes: 35
Views: 270678
Reputation: 21
If java not installed yet. Then program written by java cannot be run to check if java is installed or not.
Upvotes: -1
Reputation: 49
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 .
Upvotes: 0
Reputation: 4434
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!");
Upvotes: 0
Reputation: 13844
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
Upvotes: 56
Reputation: 17
type java -version in command prompt, it will give you the installed version of java on your system.
Upvotes: 0
Reputation: 5102
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.
Upvotes: 0
Reputation: 2116
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.
Upvotes: 0
Reputation: 17595
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.
Upvotes: 9
Reputation: 6479
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.
Upvotes: 5
Reputation: 45060
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.
Upvotes: 0
Reputation: 7630
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)
Upvotes: 4
Reputation: 8096
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
Upvotes: 4