@Test public void jdkVersion() { assertEquals(4, EnvUtil.getJDKVersion("1.4.xx")); assertEquals(5, EnvUtil.getJDKVersion("1.5")); assertEquals(5, EnvUtil.getJDKVersion("1.5.xx")); assertEquals(5, EnvUtil.getJDKVersion("1.5AA")); assertEquals(9, EnvUtil.getJDKVersion("9EA")); assertEquals(9, EnvUtil.getJDKVersion("9.0.1")); assertEquals(18, EnvUtil.getJDKVersion("18.3+xx")); }
static public int getJDKVersion(String javaVersionStr) { int version = 0; for (char ch : javaVersionStr.toCharArray()) { if (Character.isDigit(ch)) { version = (version * 10) + (ch - 48); } else if (version == 1) { version = 0; } else { break; } } return version; }
EnvUtil { static public int getJDKVersion(String javaVersionStr) { int version = 0; for (char ch : javaVersionStr.toCharArray()) { if (Character.isDigit(ch)) { version = (version * 10) + (ch - 48); } else if (version == 1) { version = 0; } else { break; } } return version; } }
EnvUtil { static public int getJDKVersion(String javaVersionStr) { int version = 0; for (char ch : javaVersionStr.toCharArray()) { if (Character.isDigit(ch)) { version = (version * 10) + (ch - 48); } else if (version == 1) { version = 0; } else { break; } } return version; } private  EnvUtil(); }
EnvUtil { static public int getJDKVersion(String javaVersionStr) { int version = 0; for (char ch : javaVersionStr.toCharArray()) { if (Character.isDigit(ch)) { version = (version * 10) + (ch - 48); } else if (version == 1) { version = 0; } else { break; } } return version; } private  EnvUtil(); static int getJDKVersion(String javaVersionStr); static boolean isJDK5(); static boolean isJDK6OrHigher(); static boolean isJDK7OrHigher(); static boolean isJaninoAvailable(); static boolean isWindows(); }
EnvUtil { static public int getJDKVersion(String javaVersionStr) { int version = 0; for (char ch : javaVersionStr.toCharArray()) { if (Character.isDigit(ch)) { version = (version * 10) + (ch - 48); } else if (version == 1) { version = 0; } else { break; } } return version; } private  EnvUtil(); static int getJDKVersion(String javaVersionStr); static boolean isJDK5(); static boolean isJDK6OrHigher(); static boolean isJDK7OrHigher(); static boolean isJaninoAvailable(); static boolean isWindows();  }