Check Java version / type from code

Basically, I am trying to determine if a user is using IBM JDK or Oracle JDK inside the code itself, but cannot come up with an elegant solution outside of using command line arguments and using a string tokenizer. Does anyone know an API or a proprietary method to discover these details?

+4
source share
2 answers

For provider and version

System.out.println(System.getProperty("java.vendor"));
System.out.println(System.getProperty("java.version"));
+6
source

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 you jdkthe vendor version .

Output:

Oracle Corporation
1.7.0_25
+5
source

Source: https://habr.com/ru/post/1523871/


All Articles