Find out 32 bit or 64 bit java jdk version in Java

http://www.cloudhadoop.com/2012/01/find-out-32-bit-jvm-version-or-not-in.html

I have encountered one of the issue with java installation which is not combatable with my 32 bit machine.

32 bit is 4 bytes of size, where as 64 bit is 8 bytes of size. That means 64 bit takes more memory than 32 machines
Most of the times, if your code is complied with 32 bit jdk version, then you need to execute this class files in 32 bit machine/64 bit machine only. This will complies and executes fine, but in some cases if there is machine specific , you are in trouble with issues,so careful while installing jdk versions.

32 bit JVM is not compatible with other 64 bit hosts/frameworks as i have encountered issues tomcat 64 bit on java 32 bit

I am listing down the ways to find out the 32 bit vs 64 bit

As per Sun Specification "There is no public API to find out the 32 bit or 64 bit".

There are number of ways to find out the 32bit version or not.

One way is as "sun.arch.data.model" is one of the system property in JVM which has 32 bit or 64 bit or unknown, so we have to write a simple program to read the property value

So i have written sample code to find out bit version

public class BitVersionDemo {
 public static void main(String args[]) {
  System.out.println("version ="
    + System.getProperty("sun.arch.data.model"));
 }
}


and the output is
version =32
that means your installed jdk is 32 bit

on Linux :-

so if your system is installed java 64 bit, by running java -d32 command it gives the following message

bash-3.2$ java -d32 -version
Running a 32-bit JVM is not supported on this platform.


By giving -d64 command, the following informationn is displayed

-bash-3.2$ java -d64 -version
java version "1.6.0_27"
Java(TM) SE Runtime Environment (build 1.6.0_27-b07)
Java HotSpot(TM) 64-Bit Server VM (build 20.2-b06, mixed mode)


On windows, "java -d32 -version" is giving error so you can write above samle to find out the version

Hope this helps for your debugging.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值