org.springframework.core
abstract public class: JdkVersion [javadoc |
source]
java.lang.Object
org.springframework.core.JdkVersion
Internal helper class used to find the Java/JDK version
that Spring is operating on, to allow for automatically
adapting to the present platform's capabilities.
Note that Spring requires JVM 1.4 or higher, as of Spring 2.5.
- author:
Rod - Johnson
- author:
Juergen - Hoeller
- author:
Rick - Evans
| Field Summary |
|---|
| public static final int | JAVA_13 | Constant identifying the 1.3.x JVM (JDK 1.3). |
| public static final int | JAVA_14 | Constant identifying the 1.4.x JVM (J2SE 1.4). |
| public static final int | JAVA_15 | Constant identifying the 1.5 JVM (Java 5). |
| public static final int | JAVA_16 | Constant identifying the 1.6 JVM (Java 6). |
| public static final int | JAVA_17 | Constant identifying the 1.7 JVM (Java 7). |
| Method from org.springframework.core.JdkVersion Detail: |
public static String getJavaVersion() {
javaVersion = System.getProperty("java.version");
// version String should look like "1.4.2_10"
if (javaVersion.indexOf("1.7.") != -1) {
majorJavaVersion = JAVA_17;
}
else if (javaVersion.indexOf("1.6.") != -1) {
majorJavaVersion = JAVA_16;
}
else if (javaVersion.indexOf("1.5.") != -1) {
majorJavaVersion = JAVA_15;
}
else {
// else leave 1.4 as default (it's either 1.4 or unknown)
majorJavaVersion = JAVA_14;
}
return javaVersion;
}
Return the full Java version string, as returned by
System.getProperty("java.version"). |
public static int getMajorJavaVersion() {
return majorJavaVersion;
}
Get the major version code. This means we can do things like
if (getMajorJavaVersion() < JAVA_14). |
public static boolean isAtLeastJava14() {
return true;
}
Convenience method to determine if the current JVM is at least Java 1.4. |
public static boolean isAtLeastJava15() {
return getMajorJavaVersion() >= JAVA_15;
}
Convenience method to determine if the current JVM is at least
Java 1.5 (Java 5). |
public static boolean isAtLeastJava16() {
return getMajorJavaVersion() >= JAVA_16;
}
Convenience method to determine if the current JVM is at least
Java 1.6 (Java 6). |