org.apache.commons.lang3.JavaVersion Java Examples
The following examples show how to use
org.apache.commons.lang3.JavaVersion.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VersionUtils.java From rug-cli with GNU General Public License v3.0 | 6 votes |
public static void validateJdkVersion() { boolean warn = false; if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)) { // We need 1.8.0_111 at least String version = SystemUtils.JAVA_VERSION; int ix = version.lastIndexOf('_'); if (ix > 0) { int patch = Integer.valueOf(version.substring(ix + 1)); if (patch < 111) { warn = true; } } } else { // Not even Java 1.8 warn = true; } if (warn) { new Log(VersionUtils.class).info(Style.yellow( "Please update your Java™ Runtime Environment (JRE) from %s to version 1.8.0_111 or newer.", SystemUtils.JAVA_VERSION)); } }
Example #2
Source File: JvmCheck.java From cuba with Apache License 2.0 | 6 votes |
@Override public List<CheckFailedResult> doCheck() { List<CheckFailedResult> result = new ArrayList<>(); String javaVersion = SystemUtils.JAVA_VERSION; if (!SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8) || !SystemUtils.isJavaVersionAtMost(JavaVersion.JAVA_11)) { result.add(new CheckFailedResult( String.format("Unsupported Java version detected: %s; Cuba supports Java 8, 9 or 11", javaVersion), null)); } Properties prop = System.getProperties(); String vendor = prop.getProperty("java.vendor"); // Since OpenJ9 JVM is unsupported if (vendor != null && vendor.contains("OpenJ9")) { result.add(new CheckFailedResult( String.format("Possibly unsupported JVM from vendor: %s", vendor), null)); } return result; }
Example #3
Source File: JdkGenericDumpTestCase.java From commons-bcel with Apache License 2.0 | 5 votes |
@Test public void testJreModules() throws Exception { Assume.assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)); try (final ModularRuntimeImage mri = new ModularRuntimeImage(javaHome)) { final List<Path> modules = mri.modules(); Assert.assertFalse(modules.isEmpty()); for (final Path path : modules) { Files.walkFileTree(path, new ClassParserFilesVisitor("*.class")); } } }
Example #4
Source File: ScriptRunnerFactory.java From citeproc-java with Apache License 2.0 | 5 votes |
/** * Creates a new {@link ScriptRunner} instance according to the * type set with {@link #setRunnerType(RunnerType)} * @return the script runner */ public static ScriptRunner createRunner() { RunnerType t = runner.get(); switch (t) { case AUTO: if (supportsV8()) { return createV8Runner(); } if (SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_11)) { return createGraalRunner(); } // fall back to JRE return createJreRunner(); case JRE: return createJreRunner(); case V8: return createV8Runner(); case GRAALJS: return createGraalRunner(); default: throw new RuntimeException("Invalid runner type"); } }
Example #5
Source File: ModularRuntimeImageTestCase.java From commons-bcel with Apache License 2.0 | 4 votes |
public ModularRuntimeImageTestCase(final String javaHome) throws IOException { this.javaHome = javaHome; Assume.assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9)); this.modularRuntimeImage = new ModularRuntimeImage(javaHome); }
Example #6
Source File: SystemsUtilsManualTest.java From tutorials with MIT License | 4 votes |
@Test public void givenSystemUtilsClass_whenCalledisJavaVersionAtLeast_thenCorrect() { assertThat(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_RECENT)).isTrue(); }
Example #7
Source File: MongoDb4TestTestRuleTest.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@BeforeClass public static void beforeClass() { Assume.assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)); }
Example #8
Source File: MongoDb3TestTestRuleTest.java From logging-log4j2 with Apache License 2.0 | 4 votes |
@BeforeClass public static void beforeClass() { Assume.assumeTrue(SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_1_8)); }
Example #9
Source File: IntegrationTestBase.java From jarjar with Apache License 2.0 | 2 votes |
/** * Returns true if the system java version is at least as great as the input java version. * * @param version The java version, formated as %d.%d (eg, 1.8). * @return */ public boolean javaVersionIsAtLeast(String version) { String enumName = "JAVA_" + version.replace('.', '_'); return SystemUtils.isJavaVersionAtLeast(JavaVersion.valueOf(enumName)); }