Techies Experience

Thursday, March 20, 2014

JDK-32-bit JVM-vs-64-bit JVm

Technology Update : What is diffrence between 32 bit JVM and 64 bit JVM.

What is diffrence between JDK 32 bit- & JDK 64 bit JVM ?


We have used jdk many times for java development but we facing one question every time
what is diffence between 32 bit jvm and 64 bit jvm?.

What is 64 bit JVM & 32 bit JVM ?


64 bit JVM runs in the 64-bit environment of a 64-bit OS on a 64-bit processor. The major differences between 32-bit and 64-bit jvm are the sizes of machine words,
the amount of addressable memory, and the Operating System memory in use.
The main advantage of Java in a 64-bit environment is the larger address space.
This allows for a much larger Java heap size and an increased maximum number of Java Threads,which required for large applications.
many user assume that we are using 32 bit to 64 bit environment means ,
we are doubled the size of Java Integers from 32 bit to 64 bit. we are not doing any modifications in JVM releated specifications.

When to use 32 bit and 64 bit JVM ?


If Java Application running on a system is required more RAM greater than 4GB then will use 64 bit
other caes 32 bit is fine.

How to check JVM is 32 bit or 64 bit


1.Using Java Version

Case 32 bit it will print
 java version "1.6.0_24"  
 OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-i386)  
 OpenJDK Server VM (build 20.0-b12, mixed mode)  

Case 64 bit it will print
 java -version  
 java version "1.6.0_24"  
 Java(TM) SE Runtime Environment (build 1.6.0_25-b06)  
 Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)  

2.Using System property sun.arch.data.model

one more option to find find whether JVM is 32 bit or 64 bit by using System.getProperty("sun.arch.data.model") at least on Sun's hotspot JVM. for 32 bit JVM "sun.arch.data.model" will be 32 and for 64 bit JVM this would be 64.
 System.out.println("32 /64 JVM Bit size: " + System.getProperty("sun.arch.data.model"));  
 Output:  
 JVM Bit size: 32 //JVM is 32 bit  
 JVM Bit size: amd64 //JVM is 64 bit  
3.Using System.getProperty("os.arch")

"os.arch" is another System property which you can use to find whether installed JRE or JVM is 32 bit or 64 bit. by name it sounds that it will return operating system arch but you can still give it a try. Though I haven't tested on all different JVM, I have read that it can indeed return JVM Bitness.If you try this on 64 bit machine and 32 bit JVM combination than please let us know what does it return. here is what it returns in case of 32 bit JVM:
 System.out.println("JVM Bit size: " + System.getProperty("os.arch"));  
 output :  
 JVM Bit size: x86 //on 32 bit JVM  
 JVM Bit size: amd64 //on 64 bit JVM  

5.Using java -d64 -version

using this command will get the below mentioned output.
 java -d64 -version   
 This Java instance does not support a 64-bit JVM.  
 Please install the desired version.  
That's all the ways we can used to check JVM is 32 bit or 64 bit. any improvements , suggestions are highly appreciated.
some references also you can check online here.

References :
  1. Check JDK 32 bit or 64 bit @ http://www.java.com/en/download/faq/java_win64bit.xml
  2. Lotus Media Centre @ http://lotusmediacentre.com/difference-between-32-bit-and-64-bit-jvm-choose-wisely/

No comments:

Post a Comment