Example usage for org.apache.commons.lang SystemUtils OS_ARCH

List of usage examples for org.apache.commons.lang SystemUtils OS_ARCH

Introduction

In this page you can find the example usage for org.apache.commons.lang SystemUtils OS_ARCH.

Prototype

String OS_ARCH

To view the source code for org.apache.commons.lang SystemUtils OS_ARCH.

Click Source Link

Document

The os.arch System Property.

Usage

From source file:com.skype.connector.linux.SkypeFramework.java

static void init() throws LoadLibraryException {
    synchronized (initializedFieldMutex) {
        if (!initialized) {
            if (SystemUtils.OS_ARCH.contains("64")) {
                ConnectorUtils.loadLibrary(getLibName("x64"));
            } else {
                ConnectorUtils.loadLibrary(getLibName("x86"));
            }/*from   w w  w  . j a va2s .c  om*/
            setup0();

            eventLoopFinishedLatch = new CountDownLatch(1);
            eventLoop = new Thread(new Runnable() {
                public void run() {
                    runEventLoop0();
                    eventLoopFinishedLatch.countDown();
                }
            }, "Skype4Java Event Loop");
            eventLoop.setDaemon(true);
            eventLoop.start();
            initialized = true;
        }
    }
}

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 .  ja  v a2 s  .  com
        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: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));
    }// ww  w. j a v a 2  s .  c o m

    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: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.google.gdt.eclipse.designer.mac.BrowserShellMacImplCocoa.java

private static Image createImageFromHandle(long imageHandle, int width, int height) throws Exception {
    if (imageHandle != 0) {
        Class<?> nsImageClass = Class.forName("org.eclipse.swt.internal.cocoa.NSImage");
        Object handleObject;/*ww w.j  av  a 2s .c  o m*/
        Class<?> handleClass;
        if (SystemUtils.OS_ARCH.indexOf("64") != -1) {
            handleClass = long.class;
            handleObject = new Long(imageHandle);
        } else {
            handleClass = int.class;
            handleObject = new Integer((int) imageHandle);
        }
        Constructor<?> constructor = nsImageClass.getConstructor(handleClass);
        Object nsImage = constructor.newInstance(handleObject);
        // Create a temporary image using the captured image's handle
        Class<?> NSImageClass = Class.forName("org.eclipse.swt.internal.cocoa.NSImage");
        Method method = Image.class.getDeclaredMethod("cocoa_new",
                new Class[] { Device.class, int.class, NSImageClass });
        method.setAccessible(true);
        Image tempImage = (Image) method.invoke(null,
                new Object[] { Display.getCurrent(), new Integer(SWT.BITMAP), nsImage });
        // Create the result image
        Image image = new Image(Display.getCurrent(), width, height);
        // Manually copy because the image's data handle isn't available
        GC gc = new GC(tempImage);
        gc.copyArea(image, 0, 0);
        gc.dispose();
        // Dispose of the temporary image allocated in the native call
        tempImage.dispose();
        return image;
    }
    // prevent failing
    return new Image(Display.getCurrent(), 1, 1);
}

From source file:com.yahoo.flowetl.commons.runner.Main.java

/**
 * Gets some useful runtime info as a map of names -> info.
 *//*from   ww w  .j  a va 2  s. c  o  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:org.apache.cocoon.generation.StatusGenerator.java

private void genVMStatus() throws SAXException {
    AttributesImpl atts = new AttributesImpl();
    startGroup("VM");

    // BEGIN ClassPath
    String classpath = SystemUtils.JAVA_CLASS_PATH;
    if (classpath != null) {
        List paths = new ArrayList();
        StringTokenizer tokenizer = new StringTokenizer(classpath, SystemUtils.PATH_SEPARATOR);
        while (tokenizer.hasMoreTokens()) {
            paths.add(tokenizer.nextToken());
        }/* www. ja  va  2 s .c om*/
        addMultilineValue("classpath", paths);
    }
    // END ClassPath

    // BEGIN CONTEXT CLASSPATH
    String contextClassPath = null;
    try {
        contextClassPath = (String) this.context.get(Constants.CONTEXT_CLASSPATH);
    } catch (ContextException e) {
        // we ignore this
    }
    if (contextClassPath != null) {
        List paths = new ArrayList();
        StringTokenizer tokenizer = new StringTokenizer(contextClassPath, File.pathSeparator);
        while (tokenizer.hasMoreTokens()) {
            paths.add(tokenizer.nextToken());
        }
        addMultilineValue("context-classpath", paths);
    }
    // END CONTEXT CLASSPATH

    // BEGIN Memory status
    startGroup("Memory");
    final long totalMemory = Runtime.getRuntime().totalMemory();
    final long freeMemory = Runtime.getRuntime().freeMemory();
    addValue("total", String.valueOf(totalMemory));
    addValue("used", String.valueOf(totalMemory - freeMemory));
    addValue("free", String.valueOf(freeMemory));
    endGroup();
    // END Memory status

    // BEGIN JRE
    startGroup("JRE");
    addValue("version", SystemUtils.JAVA_VERSION);
    atts.clear();
    // qName = prefix + ':' + localName
    atts.addAttribute(XLINK_NS, "type", XLINK_PREFIX + ":type", "CDATA", "simple");
    atts.addAttribute(XLINK_NS, "href", XLINK_PREFIX + ":href", "CDATA", SystemUtils.JAVA_VENDOR_URL);
    addValue("java-vendor", SystemUtils.JAVA_VENDOR, atts);
    endGroup();
    // END JRE

    // BEGIN Operating system
    startGroup("Operating System");
    addValue("name", SystemUtils.OS_NAME);
    addValue("architecture", SystemUtils.OS_ARCH);
    addValue("version", SystemUtils.OS_VERSION);
    endGroup();
    // END operating system

    // BEGIN Cache
    if (this.storeJanitor != null) {
        startGroup("Store Janitor");

        // For each element in StoreJanitor
        Iterator i = this.storeJanitor.iterator();
        while (i.hasNext()) {
            Store store = (Store) i.next();
            startGroup(
                    store.getClass().getName() + " (hash = 0x" + Integer.toHexString(store.hashCode()) + ")");
            int size = 0;
            int empty = 0;
            atts.clear();
            atts.addAttribute(NAMESPACE, "name", "name", "CDATA", "cached");
            super.contentHandler.startElement(NAMESPACE, "value", "value", atts);

            atts.clear();
            Enumeration e = store.keys();
            while (e.hasMoreElements()) {
                size++;
                Object key = e.nextElement();
                Object val = store.get(key);
                String line;
                if (val == null) {
                    empty++;
                } else {
                    line = key + " (class: " + val.getClass().getName() + ")";
                    super.contentHandler.startElement(NAMESPACE, "line", "line", atts);
                    super.contentHandler.characters(line.toCharArray(), 0, line.length());
                    super.contentHandler.endElement(NAMESPACE, "line", "line");
                }
            }
            if (size == 0) {
                super.contentHandler.startElement(NAMESPACE, "line", "line", atts);
                String value = "[empty]";
                super.contentHandler.characters(value.toCharArray(), 0, value.length());
                super.contentHandler.endElement(NAMESPACE, "line", "line");
            }
            super.contentHandler.endElement(NAMESPACE, "value", "value");

            addValue("size", String.valueOf(size) + " items in cache (" + empty + " are empty)");
            endGroup();
        }
        endGroup();
    }

    if (this.storePersistent != null) {
        startGroup(storePersistent.getClass().getName() + " (hash = 0x"
                + Integer.toHexString(storePersistent.hashCode()) + ")");
        int size = 0;
        int empty = 0;
        atts.clear();
        atts.addAttribute(NAMESPACE, "name", "name", "CDATA", "cached");
        super.contentHandler.startElement(NAMESPACE, "value", "value", atts);

        atts.clear();
        Enumeration e = this.storePersistent.keys();
        while (e.hasMoreElements()) {
            size++;
            Object key = e.nextElement();
            Object val = storePersistent.get(key);
            String line;
            if (val == null) {
                empty++;
            } else {
                line = key + " (class: " + val.getClass().getName() + ")";
                super.contentHandler.startElement(NAMESPACE, "line", "line", atts);
                super.contentHandler.characters(line.toCharArray(), 0, line.length());
                super.contentHandler.endElement(NAMESPACE, "line", "line");
            }
        }
        if (size == 0) {
            super.contentHandler.startElement(NAMESPACE, "line", "line", atts);
            String value = "[empty]";
            super.contentHandler.characters(value.toCharArray(), 0, value.length());
            super.contentHandler.endElement(NAMESPACE, "line", "line");
        }
        super.contentHandler.endElement(NAMESPACE, "value", "value");

        addValue("size", size + " items in cache (" + empty + " are empty)");
        endGroup();
    }
    // END Cache

    endGroup();
}

From source file:org.apache.cocoon.webservices.system.System.java

/**
 * <code>getArchitecture</code> returns the host architecture.
 *
 * @return host architecture
 */
public String getArchitecture() {
    return SystemUtils.OS_ARCH;
}

From source file:org.apache.sysml.utils.NativeHelper.java

/**
 * Note: we only support 64 bit Java on x86 and AMD machine
 * //from w w w .j  ava2s.  c o  m
 * @return true if the hardware architecture is supported
 */
private static boolean isSupportedArchitecture() {
    if (SystemUtils.OS_ARCH.equals("x86_64") || SystemUtils.OS_ARCH.equals("amd64")) {
        return true;
    }
    LOG.info("Unsupported architecture for native BLAS:" + SystemUtils.OS_ARCH);
    return false;
}

From source file:org.cleartk.util.PlatformDetection.java

public PlatformDetection() {
    // resolve OS
    if (SystemUtils.IS_OS_WINDOWS) {
        this.os = OS_WINDOWS;
    } else if (SystemUtils.IS_OS_MAC_OSX) {
        this.os = OS_OSX;
    } else if (SystemUtils.IS_OS_SOLARIS) {
        this.os = OS_SOLARIS;
    } else if (SystemUtils.IS_OS_LINUX) {
        this.os = OS_LINUX;
    } else {//  w w  w.  jav  a 2 s . c  o m
        throw new IllegalArgumentException("Unknown operating system " + SystemUtils.OS_NAME);
    }

    // resolve architecture
    Map<String, String> archMap = new HashMap<String, String>();
    archMap.put("x86", ARCH_X86_32);
    archMap.put("i386", ARCH_X86_32);
    archMap.put("i486", ARCH_X86_32);
    archMap.put("i586", ARCH_X86_32);
    archMap.put("i686", ARCH_X86_32);
    archMap.put("x86_64", ARCH_X86_64);
    archMap.put("amd64", ARCH_X86_64);
    archMap.put("powerpc", ARCH_PPC);
    this.arch = archMap.get(SystemUtils.OS_ARCH);
    if (this.arch == null) {
        throw new IllegalArgumentException("Unknown architecture " + SystemUtils.OS_ARCH);
    }
}