Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect running JDK

Tags:

java

openjdk

On Linux OS both OpenJDK and Oracle JDK java variables Return the same results. How can I detect whether running Java is OpenJDK or Orackle JDK?

Code:

System.out.println("java.vendor: " + System.getProperty("java.vendor"));
System.out.println("java.version: " + System.getProperty("java.version"));
System.out.println("java.vendor.url: " + System.getProperty("java.vendor.url"));

Output:

java.vendor: Oracle Corporation
java.version: 1.7.0_55
java.vendor.url: http://java.oracle.com/

java -version command for two JDK is:

java version "1.7.0_55"
OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)

java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Server VM (build 24.51-b03, mixed mode)
like image 928
jdiver Avatar asked Apr 21 '14 13:04

jdiver


1 Answers

Try:

System.out.println(System.getProperty("java.vm.name"));
like image 132
Artur Malinowski Avatar answered Nov 14 '22 21:11

Artur Malinowski