Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Determining JVM bit version (32bit or 64bit) at runtime

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Determining JVM bit version (32bit or 64bit) at runtime

    Hello,

    I am a Java beginner and facing problem at JNI level. I have to load a C++ library through my JNI layer and the problem is my JNI (/JAVA) code is
    same for 32bit and 64bit JVM. 2 different processes will use this code and 1 will run under 32JVM and another under 64JVM.
    Hence I have to load 32bit C++ library in one process instance and 64bith C++ library in another.

    I found this way to determine the JVM bit version during run time,

    static {
    String jvmModel = System.getProperty("sun.arch.data.model");
    if(jvmModel.equals("64"))
    {
    System.loadLibrary("library64");
    }
    else
    {
    System.loadLibrary("library32");
    }
    }

    but my question is, is this portable? as it appears to me it will run only in SUN JVM. If not portable what is the portable way?

    Best REgards,
    Ananth


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Determining JVM bit version (32bit or 64bit) at runtime

    Note that the sun.arch.data.model property may also return unknown, so you may wish to handle this property as well. And whether this is portable - only on the systems you have compiled your JNI. What about Mac? Windows? Linux?

Similar Threads

  1. A J2ME code for determining mobile phone's free space. Please help.
    By marksquall in forum Java ME (Mobile Edition)
    Replies: 0
    Last Post: November 28th, 2011, 09:35 PM
  2. Help determining which day a particular date falls on.
    By Prox in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 7th, 2011, 11:49 PM
  3. Version issue? Or what else can it be?
    By SxN in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 17th, 2011, 05:53 PM
  4. Basic OOP having trouble determining how to handle methods
    By Nikkon2131 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: July 21st, 2011, 06:15 PM
  5. Determining Linear Approximations
    By ddunlop07 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 13th, 2011, 12:12 AM