How do I detect which kind of JRE is installed — 32bit vs. 64bit

前端 未结 9 1132
离开以前
离开以前 2020-11-27 03:47

During installation with an NSIS installer, I need to check which JRE (32bit vs 64bit) is installed on a system. I already know that I can check a system property \"su

9条回答
  •  迷失自我
    2020-11-27 04:38

    import sun.misc.*;
    
    import java.lang.reflect.*;
    
    public class UnsafeTest {
      public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
        unsafeField.setAccessible(true);
        Unsafe unsafe = (Unsafe) unsafeField.get(null);
        System.out.println(unsafe.addressSize());
      }
    }
    

提交回复
热议问题