Java: How to check jdk version?

Possible duplicate:
How to find out the JDK version from Java code

In my java code, I want to check the jdk version. If it is equal to 1.5 or higher, and only I want to continue execution. How to get jdk version?

+4
source share
3 answers

Use this condition.

 Integer.parseInt(System.getProperty("java.version").split("\\.")[1]) >= 5 

to check the version of Java.

+8
source
 String version = System.getProperty("java.version"); 
+3
source
 String version = System.getProperty("java.specification.version"); 

This will give you line 1.5 , for example. Easy to take apart.

+3
source

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


All Articles