java jnlp - All possible values os.arch in 32bit JRE and in 64bit Jre




download install (3)

You can also write some code like below to find out os and its archi.

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang.SystemUtils;


public class PlatformDetection {
    private String os;
    private String arch;
    public static String OS_WINDOWS = "windows";
    public static String OS_OSX = "osx";
    public static String OS_SOLARIS = "solaris";
    public static String OS_LINUX = "linux";
    public static String ARCH_PPC = "ppc";
    public static String ARCH_X86_32 = "x86_32";
    public static String ARCH_X86_64 = "x86_64";

    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 {
            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);
        }
    }

    public String getOs() {
        return os;
    }

    public String getArch() {
        return arch;
    }

    public void setArch(String arch) {
        this.arch = arch;
    }

    public void setOs(String os) {
        this.os = os;
    }

    public String toString() {

        return os + "_" + arch;
    }
}

Refer below Links

  1. https://github.com/trustin/os-maven-plugin/blob/master/src/main/java/kr/motd/maven/os/Detector.java

  2. https://github.com/rachelxqy/EligibilityCriteriaModeling/blob/57001f6d86084f074f4ca6aaff157e93ef6abf95/src/main/java/edu/mayo/bmi/medtagger/ml/util/PlatformDetection.java

I need latest compilation of all possible values of the os.arch property in JRE 1.6 on Linux,Solaris and Windows. If possible please Quote the source of your findings. I need this values to select resources in my JNLP file. Basically I need to assign different JVM memory based on whether the JRE is 32bit or 64bit. Waiting for your answer. Thanks


The best place where you can look for this it's in the own jdk.

Looking on java.lang.System you can see that the properties are initialized in initializeSystemClass method using initProperties method which relies on native code using JNI:

private static native Properties initProperties(Properties props);

/**
 * Initialize the system class.  Called after thread initialization.
 */
private static void initializeSystemClass() {

    // VM might invoke JNU_NewStringPlatform() to set those encoding
    // sensitive properties (user.home, user.name, boot.class.path, etc.)
    // during "props" initialization, in which it may need access, via
    // System.getProperty(), to the related system encoding property that
    // have been initialized (put into "props") at early stage of the
    // initialization. So make sure the "props" is available at the
    // very beginning of the initialization and all system properties to
    // be put into it directly.
    props = new Properties();
    initProperties(props);  // initialized by the VM
    ...
    ...
}

If you check the source of this native code called from initProperties for the different platforms you can see the possible values for os.arch system property. So do it step by step:

First look at System.c to see the JNI method called from java.lang.System.initProperties. From System.c

JNIEXPORT jobject JNICALL
Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props)
{
    char buf[128];
    java_props_t *sprops = GetJavaProperties(env);
    jmethodID putID = (*env)->GetMethodID(env,
                                          (*env)->GetObjectClass(env, props),
                                          "put",
            "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;");

    if (sprops == NULL || putID == NULL ) return NULL;

    PUTPROP(props, "java.specification.version",
            JDK_MAJOR_VERSION "." JDK_MINOR_VERSION);
    PUTPROP(props, "java.specification.name",
            "Java Platform API Specification");
    PUTPROP(props, "java.specification.vendor", "Sun Microsystems Inc.");

    PUTPROP(props, "java.version", RELEASE);
    PUTPROP(props, "java.vendor", VENDOR);
    PUTPROP(props, "java.vendor.url", VENDOR_URL);
    PUTPROP(props, "java.vendor.url.bug", VENDOR_URL_BUG);

    ...

    /* os properties */
    PUTPROP(props, "os.name", sprops->os_name);
    PUTPROP(props, "os.version", sprops->os_version);

    // HERE IS THE `os.arch` PROPERTY :)

    PUTPROP(props, "os.arch", sprops->os_arch);

So as you can see the os.arch comes from PUTPROP(props, "os.arch", sprops->os_arch); and the sprops it's achieved using java_props_t *sprops = GetJavaProperties(env);. so lets look at GetJavaProperties(env), this method it's defined in java_props.h as:

java_props_t *GetJavaProperties(JNIEnv *env);

And the implementation seems that depends on OS.

So finally looking a specific implementation for GetJavaProperties; in Windows the possible values which this property can take are ia64, amd64, x86, or unknown. You can see from java_props_md.c file :

#if _M_IA64
        sprops.os_arch = "ia64";
#elif _M_AMD64
        sprops.os_arch = "amd64";
#elif _X86_
        sprops.os_arch = "x86";
#else
        sprops.os_arch = "unknown";
#endif

For Solaris seems more complicated since the property value in the native code comes from a Macro defined in the java_props_md.c specific for solaris as:

sprops.os_arch = ARCHPROPNAME;

And this Macro it's defined in the follow Makefile as:

OTHER_CPPFLAGS += -DARCHPROPNAME='"$(ARCHPROP)"'

So it looks like this comes from the environment, where it's compiled (sorry I'm not a C expert, I'm just guessing however maybe I can guide you a bit).

In the Linux folder in src/linux/native/ there is no java_props_md.c so I suppose that in this case take the same source as solaris (I'm guessing again...).

NOTE: I use the 1.6 version to get this values, however new values can will be added in newest java versions, so check your required version.

Hope it helps,








java jnlp