views:

81

answers:

3

Hi All,

I'm writing a JNI application and I want the app to download the correct binary library for the current architecture. Is there any way to retrieve this information from code?

I need to know where it's ARM, x86 or any other architecture really.

Kind regards,

Gavin

A: 

This works in Java 6SE:

public class ListProperties
{
     public static void main(String[] argv)
     {
        System.getProperties().list(System.out);
        // These are only examples of obtaining specific properties
        System.out.println(System.getProperty("user.name"));
        System.out.println(System.getProperty("java.library.path"));
     }
}
Gary Chambers
+1  A: 
System.getProperty("os.arch")

http://www.roseindia.net/java/beginners/OSInformation.shtml

David Johnstone
+4  A: 

java.lang.System.getProperty("os.arch") should help -- giving "arm", "amd64", and the like.

Alex Martelli