1 package net.sf.openrocket.startup;
3 import net.sf.openrocket.logging.LogHelper;
5 public class VersionHelper {
7 private static final LogHelper log = Application.getLogger();
9 private static final int REQUIRED_MAJOR_VERSION = 1;
10 private static final int REQUIRED_MINOR_VERSION = 6;
12 // OpenJDK 1.6.0_0-b16 is known to work, 1.6.0_0-b12 does not
13 private static final String BAD_OPENJDK_VERSION = "^1.6.0_0-b([0-9]|1[1-5])$";
17 * Check that the JRE version is high enough.
19 static void checkVersion() {
21 String[] version = System.getProperty("java.specification.version", "").split("\\.");
23 String jreName = System.getProperty("java.vm.name", "(unknown)");
24 String jreVersion = System.getProperty("java.runtime.version", "(unknown)");
25 String jreVendor = System.getProperty("java.vendor", "(unknown)");
27 log.info("Running JRE " + jreName + " version " + jreVersion + " by " + jreVendor);
32 major = Integer.parseInt(version[0]);
33 minor = Integer.parseInt(version[1]);
35 if (major < REQUIRED_MAJOR_VERSION ||
36 (major == REQUIRED_MAJOR_VERSION && minor < REQUIRED_MINOR_VERSION)) {
37 Startup.error(new String[] { "Java SE version 6 is required to run OpenRocket.",
38 "You are currently running " + jreName + " version " +
39 jreVersion + " by " + jreVendor });
42 } catch (RuntimeException e) {
44 Startup.confirm(new String[] { "The Java version in use could not be detected.",
45 "OpenRocket requires at least Java SE 6.",
46 "Continue anyway?" });
53 * Check whether OpenJDK is being used, and if it is warn the user about
54 * problems and confirm whether to continue.
56 static void checkOpenJDK() {
58 if (System.getProperty("java.runtime.name", "").toLowerCase().indexOf("icedtea") >= 0 ||
59 System.getProperty("java.vm.name", "").toLowerCase().indexOf("openjdk") >= 0) {
61 String jreName = System.getProperty("java.vm.name", "(unknown)");
62 String jreVersion = System.getProperty("java.runtime.version", "(unknown)");
63 String jreVendor = System.getProperty("java.vendor", "(unknown)");
65 if (jreVersion.matches(BAD_OPENJDK_VERSION)) {
67 Startup.confirm(new String[] { "Old versions of OpenJDK are known to have problems " +
68 "running OpenRocket.",
70 "You are currently running " + jreName + " version " +
71 jreVersion + " by " + jreVendor,
72 "Do you want to continue?" });