List of usage examples for org.apache.commons.lang SystemUtils OS_NAME
String OS_NAME
To view the source code for org.apache.commons.lang SystemUtils OS_NAME.
Click Source Link
The os.name
System Property.
From source file:SystemUtilsTrial.java
public static void main(String[] args) { System.out.println("1) FILE_SEPARATOR =" + SystemUtils.FILE_SEPARATOR); System.out.println("2) JAVA_EXT_DIRS =" + SystemUtils.JAVA_EXT_DIRS); System.out.println("3) JAVA_HOME =" + SystemUtils.JAVA_HOME); System.out.println("4) Is 1.3 + =" + SystemUtils.isJavaVersionAtLeast(1.3f)); System.out.println("5) JAVA_EXT_DIRS =" + SystemUtils.JAVA_EXT_DIRS); System.out.println("6) JAVA_VENDOR =" + SystemUtils.JAVA_VENDOR); System.out.println("7) OS_NAME =" + SystemUtils.OS_NAME); }
From source file:com.google.gdt.eclipse.designer.webkit.BrowserShellFactory.java
public IBrowserShell create() throws Exception { boolean is64bit = SystemUtils.OS_ARCH.indexOf("64") != -1; if (SystemUtils.OS_NAME.startsWith("Windows")) { boolean isXP = SystemUtils.OS_NAME.indexOf("XP") != -1 || SystemUtils.OS_NAME.indexOf("2003") != -1; // forcibly use WebKit for 64-bit Windows and not use in Windows XP due to bug in cairo. boolean useWebKitWin = (useWebKit() | is64bit) & !isXP; if (!useWebKitWin) { // early exit to prevent possible long deployment operation return null; }/*from w w w . j av a 2 s . c o m*/ WebKitSupportWin32.deployIfNeededAndLoad(); if (WebKitSupportWin32.isAvailable()) { return is64bit ? new BrowserShellWebKit<Long>(BrowserShellWebKitImplWin32.newImpl64()) : new BrowserShellWebKit<Integer>(BrowserShellWebKitImplWin32.newImpl32()); } } else if (SystemUtils.OS_NAME.startsWith("Linux")) { if (useWebKit() && BrowserShellWebKitImplLinux.isAvailable()) { return is64bit ? new BrowserShellWebKit<Long>(BrowserShellWebKitImplLinux.newImpl64()) : new BrowserShellWebKit<Integer>(BrowserShellWebKitImplLinux.newImpl32()); } } else if (SystemUtils.OS_NAME.startsWith("Mac")) { if ("cocoa".equals(SWT.getPlatform())) { // cocoa return is64bit ? new BrowserShellWebKit<Long>(BrowserShellWebKitImplMacCocoa.newImpl64()) : new BrowserShellWebKit<Integer>(BrowserShellWebKitImplMacCocoa.newImpl32()); } else { return new BrowserShellWebKit<Integer>(new BrowserShellWebKitImplMacCarbon()); } } // not available/not supported. return null; }
From source file:de.pawlidi.openaletheia.license.LicenseHandlerTest.java
@BeforeClass public static void setUpBeforeClass() throws Exception { KeyPair keyPair = CipherUtils.generateKeyPair(); publicKey = CipherUtils.getPublicKey(keyPair); privateKey = CipherUtils.getPrivateKey(keyPair); license = new License(); license.setProduct("License product"); license.setProductVersion("1.2.0"); license.setUuid(UUID.randomUUID().toString()); license.setMaxHost(3L);//from w ww . j a v a 2 s . c o m license.setAddress(AletheiaUtils.getMacAddress()); license.setOwner(SystemUtils.USER_NAME); license.setOperatingSystem(SystemUtils.OS_NAME); license.setCompany("Company abc"); license.setMaxUser(3L); license.setCreated(DateTime.now()); license.setDescription("License file for license product"); }
From source file:com.cloudera.cdk.morphline.solr.EnvironmentTest.java
@Test public void testEnvironment() throws UnknownHostException { System.out.println("EXPECTED_SOLR_VERSION: " + EXPECTED_SOLR_VERSION); System.out.println("Running test suite with java version: " + SystemUtils.JAVA_VERSION + " " + SystemUtils.JAVA_VM_NAME + " on " + SystemUtils.OS_NAME + " " + SystemUtils.OS_VERSION + "/" + SystemUtils.OS_ARCH + " on host: " + InetAddress.getLocalHost().getHostName()); Package p = SolrCore.class.getPackage(); System.out.println("Running test suite with solr-spec-version: " + p.getSpecificationVersion() + ", solr-impl-version: " + p.getImplementationVersion()); if (EXPECTED_SOLR_VERSION != null) { assertTrue("unexpected version: " + p.getSpecificationVersion(), p.getSpecificationVersion().startsWith(EXPECTED_SOLR_VERSION)); assertTrue("unexpected version: " + p.getImplementationVersion(), p.getImplementationVersion().startsWith(EXPECTED_SOLR_VERSION)); }/*from w ww .jav a 2 s . c om*/ p = LucenePackage.class.getPackage(); System.out.println("Running test suite with lucene-spec-version: " + p.getSpecificationVersion() + ", lucene-impl-version: " + p.getImplementationVersion()); if (EXPECTED_SOLR_VERSION != null) { assertTrue("unexpected version: " + p.getSpecificationVersion(), p.getSpecificationVersion().startsWith(EXPECTED_SOLR_VERSION)); assertTrue("unexpected version: " + p.getImplementationVersion(), p.getImplementationVersion().startsWith(EXPECTED_SOLR_VERSION)); Version expectedMinorLuceneVersion = getMinorLuceneVersion(EXPECTED_SOLR_VERSION); System.out.println("expectedMinorLuceneVersion: " + expectedMinorLuceneVersion); assertTrue(Version.LUCENE_CURRENT.onOrAfter(expectedMinorLuceneVersion)); } }
From source file:de.pawlidi.openaletheia.license.LicenseLoaderTest.java
/** * @throws java.lang.Exception/*from w w w. j ava2 s .c o m*/ */ @Before public void setUp() throws Exception { licenseLoader = new LicenseLoader(Constants.ALETHEIA_PUBLIC_KEY); properties = new Properties(); LicenseGenerator generator = new LicenseGenerator(Constants.ALETHEIA_PRIVATE_KEY); License license = new License(); license.setProduct("License product"); license.setProductVersion("1.2.0"); license.setUuid(UUID.randomUUID().toString()); license.setMaxHost(3L); license.setAddress(AletheiaUtils.getMacAddress()); license.setOwner(SystemUtils.USER_NAME); license.setOperatingSystem(SystemUtils.OS_NAME); license.setCompany("Company abc"); license.setMaxUser(3L); license.setCreated(DateTime.now()); license.setDescription("License file for license product"); generator.generate(license); generator.storeLicense("test.license", "My Test license file"); }
From source file:com.enonic.cms.web.boot.BootEnvironment.java
private String getFormattedOsInfo() { final StringBuilder str = new StringBuilder(); str.append(SystemUtils.OS_NAME).append(" ").append(SystemUtils.OS_VERSION).append(" (") .append(SystemUtils.OS_ARCH).append(")"); return str.toString(); }
From source file:com.yahoo.flowetl.commons.runner.Main.java
/** * Gets some useful runtime info as a map of names -> info. *//*from www .j a va 2 s. co m*/ private static Map<String, Object> getRuntimeInfo() { Map<String, Object> sysInfo = new TreeMap<String, Object>(); StringBuilder jvminfo = new StringBuilder(); jvminfo.append("Vendor: "); jvminfo.append(SystemUtils.JAVA_VENDOR); jvminfo.append(", Version: "); jvminfo.append(SystemUtils.JAVA_VERSION + " - " + SystemUtils.JAVA_VM_INFO); jvminfo.append(", OS: "); jvminfo.append(SystemUtils.OS_NAME + " (" + SystemUtils.OS_VERSION + " : " + SystemUtils.OS_ARCH + ")"); sysInfo.put(WordUtils.capitalizeFully("jvm"), jvminfo.toString()); sysInfo.put(WordUtils.capitalizeFully("default charset encoding"), DEF_CHAR_SET.name()); String netAdd = NetUtils.getLocalAddress(); if (StringUtils.isEmpty(netAdd)) { netAdd = "????"; } String localName = NetUtils.getLocalHostName(); if (StringUtils.isEmpty(localName)) { localName = "????"; } sysInfo.put(WordUtils.capitalizeFully("network"), localName + " at ip address " + netAdd); String cPath = SystemUtils.JAVA_CLASS_PATH; String linesep = StringEscapeUtils.escapeJava(SystemUtils.LINE_SEPARATOR); sysInfo.put(WordUtils.capitalizeFully("classpath"), cPath); sysInfo.put(WordUtils.capitalizeFully("jvm home"), SystemUtils.JAVA_HOME); sysInfo.put(WordUtils.capitalizeFully("jvm tmpdir"), SystemUtils.JAVA_IO_TMPDIR); sysInfo.put(WordUtils.capitalizeFully("jvm libpath"), SystemUtils.JAVA_LIBRARY_PATH); sysInfo.put(WordUtils.capitalizeFully("line separator"), linesep); sysInfo.put(WordUtils.capitalizeFully("path separator"), StringEscapeUtils.escapeJava(SystemUtils.PATH_SEPARATOR)); sysInfo.put(WordUtils.capitalizeFully("user timezone"), SystemUtils.USER_TIMEZONE); sysInfo.put(WordUtils.capitalizeFully("user home"), SystemUtils.USER_HOME); sysInfo.put(WordUtils.capitalizeFully("user language"), SystemUtils.USER_LANGUAGE); sysInfo.put(WordUtils.capitalizeFully("user name"), SystemUtils.USER_NAME); return sysInfo; }
From source file:net.java.jpatch.maven.ReleaseMojo.java
/** * Creates the release package.//from w w w . j a v a 2 s . co m * * @throws MojoExecutionException if the method fails. * @throws MojoFailureException if the method fails. */ @Override public void execute() throws MojoExecutionException, MojoFailureException { // Search for existing release Artifact releaseArtifact = resolveReleaseArtifact(); File releaseFile = releaseArtifact.getFile(); // Check existing release if (releaseFile != null && releaseFile.exists()) { getLog().info(releaseFile.getAbsolutePath()); getLog().error("Release file already exist! For new release execute first jpatch:release-clean."); throw new MojoFailureException("Release package already exist!"); } // Create release directory File directory = createTargetDirectory(releaseArtifact.getVersion()); // Create release properties file. Properties releaseProperties = new Properties(); // Load projects List<MavenProject> mavenProjects = loadMavenProjects(); // Filter the projects List<MavenProject> filterProjects = filterMavenProjects(mavenProjects, getPackages()); // Unpack the libraries in the output directory for (MavenProject project : filterProjects) { String revision = scmRevision(project); releaseProperties.setProperty(project.getId(), revision); Artifact artifact = project.getArtifact(); resolveArtifactFromLocalRepository(artifact); unpackArtifactFile(directory, artifact.getFile()); } // Setup the advanced properties to the release property SimpleDateFormat sdf = new SimpleDateFormat(); releaseProperties.put(RELEASE_PROPERTY_DATE, sdf.format(new Date())); releaseProperties.put(RELEASE_PROPERTY_USER_NAME, SystemUtils.USER_NAME); releaseProperties.put(RELEASE_PROPERTY_JAVA_VERSION, SystemUtils.JAVA_VERSION); releaseProperties.put(RELEASE_PROPERTY_OS_NAME, SystemUtils.OS_NAME); // Save release properties file try { File propFile = new File(mavenProject.getBuild().getDirectory(), mavenProject.getBuild().getFinalName() + ".properties"); releaseProperties.store(new FileOutputStream(propFile), null); } catch (IOException e) { throw new MojoExecutionException("Error creating the release properties file!", e); } // Create package file String fileName = mavenProject.getBuild().getFinalName(); File packFile = new File(mavenProject.getBuild().getDirectory(), fileName + ".zip"); packDirectory(directory, packFile); // Attached the package to the project releaseArtifact.setFile(packFile); mavenProject.addAttachedArtifact(releaseArtifact); // Create build file (project.jpatch) createBuildFile(); }
From source file:com.jayway.maven.plugins.android.AndroidNdk.java
public File getStripper(String toolchain) throws MojoExecutionException { final File stripper = findStripper(toolchain); if (stripper == null) { throw new MojoExecutionException("Could not resolve stripper for current OS: " + SystemUtils.OS_NAME); }//from w ww . j ava 2 s. c o m // Some basic validation if (!stripper.exists()) { throw new MojoExecutionException("Strip binary " + stripper.getAbsolutePath() + " does not exist, please double check the toolchain and OS used"); } // We should be good to go return stripper; }
From source file:net.sf.jasperreports.soutils.EnvironmentUtils.java
/** * Decides if the operating system matches. * //from w w w . j av a2 s . c o m * @param osNamePrefix * the prefix for the OS name. * @param osVersionPrefix * the prefix for the version. * @return <code>true</code> if matches, or <code>false</code> if not or can't determine. */ private static boolean getOSMatches(String osNamePrefix, String osVersionPrefix) { if (SystemUtils.OS_NAME == null || SystemUtils.OS_VERSION == null) { return false; } return SystemUtils.OS_NAME.startsWith(osNamePrefix) && SystemUtils.OS_VERSION.startsWith(osVersionPrefix); }