Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java: How to check jdk version? [duplicate]

Tags:

java

Possible Duplicate:
How to know JDK version from within Java code

In my java code I want to check jdk version. If it is 1.5 or above than & than only I want to go ahead with further execution. How to get the jdk version ?

like image 789
hemu Avatar asked Dec 03 '22 01:12

hemu


2 Answers

Use this condition

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

to check the Java version.

like image 77
Ingo Kegel Avatar answered Dec 22 '22 18:12

Ingo Kegel


String version = System.getProperty("java.specification.version");

That will give you the string 1.5 for example. Easy to parse.

like image 36
maba Avatar answered Dec 22 '22 18:12

maba