Java Code Examples for org.apache.commons.lang3.SystemUtils#OS_NAME
The following examples show how to use
org.apache.commons.lang3.SystemUtils#OS_NAME .
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: PackagerFactory.java From JavaPackager with GNU General Public License v3.0 | 5 votes |
public static Packager createPackager(Platform platform) throws MojoExecutionException { if (platform == Platform.auto) platform = Platform.getCurrentPlatform(); switch (platform) { case mac: return new MacPackager(); case linux: return new LinuxPackager(); case windows: return new WindowsPackager(); default: throw new MojoExecutionException("Unsupported operating system: " + SystemUtils.OS_NAME + " " + SystemUtils.OS_VERSION + " " + SystemUtils.OS_ARCH); } }
Example 2
Source File: UtilitiesTests.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private String getJavaHomeDirectory() { String os = SystemUtils.OS_NAME; if (os.contains(OSX) || os.contains(MAC)) { return OSX_JAVA_HOME; } else if (os.contains(LINUX)) { return LINUX_JAVA_HOME; } else if (os.toUpperCase().contains(WINDOWS)) { return WIN_JAVA_HOME; } else { throw new IllegalStateException("OS not recognized...cannot verify created directories."); } }
Example 3
Source File: UtilitiesTests.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private String getUserDirectory() { String os = SystemUtils.OS_NAME; if (os.contains(OSX) || os.contains(MAC)) { return OSX_USER_DIR; } else if (os.contains(LINUX)) { return LINUX_USER_DIR; } else if (os.toUpperCase().contains(WINDOWS)) { return WIN_USER_DIR; } else { throw new IllegalStateException("OS not recognized...cannot verify created directories."); } }
Example 4
Source File: UtilitiesTests.java From org.hl7.fhir.core with Apache License 2.0 | 5 votes |
private String getTempDirectory() throws IOException { String os = SystemUtils.OS_NAME; if (os.contains(OSX) || os.contains(MAC)) { return getOsxTempDir(); } else if (os.contains(LINUX)) { return LINUX_TEMP_DIR; } else if (os.toUpperCase().contains(WINDOWS)) { return WIN_TEMP_DIR; } else { throw new IllegalStateException("OS not recognized...cannot verify created directories."); } }
Example 5
Source File: ExprGetSysProp.java From skUtilities with GNU General Public License v3.0 | 5 votes |
@Override @Nullable protected String[] get(Event e) { switch (ty) { case 0: return new String[]{SystemUtils.OS_ARCH}; case 1: return new String[]{SystemUtils.OS_NAME}; case 2: return new String[]{SystemUtils.OS_VERSION}; case 3: return new String[]{SystemUtils.getJavaHome().toString()}; case 4: return new String[]{SystemUtils.getUserDir().toString()}; case 5: return new String[]{SystemUtils.getUserHome().toString()}; case 6: return new String[]{SystemUtils.USER_NAME}; case 7: return new String[]{SystemUtils.USER_LANGUAGE}; case 8: return new String[]{SystemUtils.USER_TIMEZONE}; case 9: return new String[]{SystemUtils.LINE_SEPARATOR}; case 10: return new String[]{SystemUtils.FILE_SEPARATOR}; case 11: return new String[]{SystemUtils.PATH_SEPARATOR}; case 12: return new String[]{SystemUtils.FILE_ENCODING}; } return null; }
Example 6
Source File: EmbeddedUtil.java From otj-pg-embedded with Apache License 2.0 | 5 votes |
/** * Get current operating system string. The string is used in the appropriate * postgres binary name. * * @return Current operating system string. */ static String getOS() { if (SystemUtils.IS_OS_WINDOWS) { return "Windows"; } if (SystemUtils.IS_OS_MAC_OSX) { return "Darwin"; } if (SystemUtils.IS_OS_LINUX) { return "Linux"; } throw new UnsupportedOperationException("Unknown OS " + SystemUtils.OS_NAME); }
Example 7
Source File: JobMonitor.java From genie with Apache License 2.0 | 5 votes |
/** * Constructor. * * @param execution The job execution object including the pid * @param stdOut The std out output file * @param stdErr The std err output file * @param genieEventBus The event bus implementation to use * @param registry The metrics event registry * @param jobsProperties The properties for jobs * @param processChecker The process checker */ JobMonitor( @Valid final JobExecution execution, @NotNull final File stdOut, @NotNull final File stdErr, @NonNull final GenieEventBus genieEventBus, @NotNull final MeterRegistry registry, @NotNull final JobsProperties jobsProperties, @NotNull final ProcessChecker processChecker ) { if (!SystemUtils.IS_OS_UNIX) { throw new UnsupportedOperationException("Genie doesn't currently support " + SystemUtils.OS_NAME); } this.errorCount = 0; this.id = execution.getId().orElseThrow(IllegalArgumentException::new); this.execution = execution; this.genieEventBus = genieEventBus; this.processChecker = processChecker; this.stdOut = stdOut; this.stdErr = stdErr; this.maxStdOutLength = jobsProperties.getMax().getStdOutSize(); this.maxStdErrLength = jobsProperties.getMax().getStdErrSize(); this.trigger = new ExponentialBackOffTrigger( ExponentialBackOffTrigger.DelayType.FROM_PREVIOUS_SCHEDULING, jobsProperties.getCompletionCheckBackOff().getMinInterval(), execution.getCheckDelay().orElse(jobsProperties.getCompletionCheckBackOff().getMaxInterval()), jobsProperties.getCompletionCheckBackOff().getFactor() ); this.successfulCheckRate = registry.counter("genie.jobs.successfulStatusCheck.rate"); this.timeoutRate = registry.counter("genie.jobs.timeout.rate"); this.finishedRate = registry.counter("genie.jobs.finished.rate"); this.unsuccessfulCheckRate = registry.counter("genie.jobs.unsuccessfulStatusCheck.rate"); this.stdOutTooLarge = registry.counter("genie.jobs.stdOutTooLarge.rate"); this.stdErrTooLarge = registry.counter("genie.jobs.stdErrTooLarge.rate"); }
Example 8
Source File: NativeBundle.java From spoofax with Apache License 2.0 | 5 votes |
/** * @return URI to the native directory. Can point to a directory on the local file system, or to a directory in a * JAR file. */ public static URI getNativeDirectory() { if(SystemUtils.IS_OS_WINDOWS) { return getResource("native/cygwin/"); } else if(SystemUtils.IS_OS_MAC_OSX) { return getResource("native/macosx/"); } else if(SystemUtils.IS_OS_LINUX) { return getResource("native/linux/"); } else { throw new UnsupportedOperationException("Unsupported platform " + SystemUtils.OS_NAME); } }
Example 9
Source File: DetectOS.java From tutorials with MIT License | 4 votes |
public String getOperatingSystemSystemUtils() { String os = SystemUtils.OS_NAME; System.out.println("Using SystemUtils: " + os); return os; }