/** * Checks the java version compared to the required one. * <p> * If major version is same as required major version and minor is greater or equal, it is compliant. * <p> * If major version is greater than required major version, it is compliant. * * @param version the java version * @param requiredVersion the required java version * @return true if the java version is compliant with the required version * @since 8.4 */ public static boolean checkJavaVersion(String version, String requiredVersion) { return checkJavaVersion(version, requiredVersion, false, false); }
/** * Check that the process is executed with a supported Java version. See * <a href="http://www.oracle.com/technetwork/java/javase/versioning-naming-139433.html">J2SE SDK/JRE Version String * Naming Convention</a> * * @since 5.6 */ public void checkJavaVersion() throws ConfigurationException { String version = System.getProperty("java.version"); checkJavaVersion(version, COMPLIANT_JAVA_VERSIONS); }
protected ScriptEngine getScriptEngine() { String version = Framework.getProperty("java.version"); // Check if jdk8 if (!checkJavaVersion(version, NASHORN_JAVA_VERSION)) { throw new UnsupportedOperationException(NASHORN_JAVA_VERSION); } // Check if version < jdk8u25 -> no cache. if (!checkJavaVersion(version, COMPLIANT_JAVA_VERSION_CACHE)) { log.warn(NASHORN_WARN_CACHE); return getScriptEngine(false, false); } boolean cache = Boolean.parseBoolean( Framework.getProperty(AUTOMATION_SCRIPTING_PRECOMPILE, DEFAULT_PRECOMPILE_STATUS)); // Check if jdk8u25 <= version < jdk8u40 -> only cache. if (!checkJavaVersion(version, COMPLIANT_JAVA_VERSION_CLASS_FILTER)) { log.warn(NASHORN_WARN_CLASS_FILTER); return getScriptEngine(cache, false); } // Else if version >= jdk8u40 -> cache + class filter try { return getScriptEngine(cache, true); } catch (NoClassDefFoundError cause) { log.warn(NASHORN_WARN_CLASS_FILTER); return getScriptEngine(cache, false); } }
if (checkJavaVersion(version, compliantVersion, false, false)) { } else if (checkJavaVersion(version, compliantVersion, true, true)) { checkJavaVersion(version, lastCompliantVersion, false, true); return;
/** * Create needed directories. Check existence of old paths. If old paths have been found and they cannot be upgraded * automatically, then upgrading message is logged and error thrown. * * @throws ConfigurationException If a deprecated directory has been detected. * @since 5.4.2 * @see ServerConfigurator#verifyInstallation() */ public void verifyInstallation() throws ConfigurationException { checkJavaVersion(); ifNotExistsAndIsDirectoryThenCreate(getLogDir()); ifNotExistsAndIsDirectoryThenCreate(getPidDir()); ifNotExistsAndIsDirectoryThenCreate(getDataDir()); ifNotExistsAndIsDirectoryThenCreate(getTmpDir()); ifNotExistsAndIsDirectoryThenCreate(getPackagesDir()); checkAddressesAndPorts(); serverConfigurator.verifyInstallation(); backingServicesConfigurator.verifyInstallation(); }