Java获取当前虚拟机32位还是64位

Java获取当前虚拟机32位还是64位:

String archdatamodel = System.getProperty("sun.arch.data.model");
if (archdatamodel.equals("32")) {
//32
} else {
//64
}

Java获取当前虚拟机架构:

String arch = System.getProperty("os.arch");
if (arch.equals("x86")) {
//x86
} else {
//amd64
}

Leave a Reply

Your email address will not be published. Required fields are marked *

*