Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check Java version/type from within code

Tags:

java

version

Basically, I'm trying to determine whether a user is using an IBM JDK or Oracle JDK from within the code itself, but can't think of an elegant solution outside of running command line arguments and using a string tokenizer. Does anybody know of an API or native method of discovering these details?

like image 659
CluEleSs_UK Avatar asked Dec 20 '22 18:12

CluEleSs_UK


2 Answers

For vendor and version

System.out.println(System.getProperty("java.vendor"));
System.out.println(System.getProperty("java.version"));
like image 62
sanbhat Avatar answered Jan 04 '23 22:01

sanbhat


You can just use

String vendor=System.getProperty("java.vendor");
String version = System.getProperty("java.version");
System.out.println(vendor);
System.out.println(version);

This will give your jdk version with the vendor.

Out put:

Oracle Corporation
1.7.0_25
like image 33
Ruchira Gayan Ranaweera Avatar answered Jan 04 '23 22:01

Ruchira Gayan Ranaweera