How To Honor If Jvm Is 32 Or 64 Flake From Coffee Program.

You tin find JVM chip size e.g. 32 chip or 64 bit past times using either running coffee ascendence from the ascendence prompt or past times using System.getProperty() from Java program. The enquiry is why produce you lot desire to know hardware or platform configuration spell writing Java code which is supposed to write i time as well as read anywhere(32 bit, 64 chip etc)? Yes nosotros don't actually ask to know whether JVM is 32 chip or 64 bit to a greater extent than oftentimes simply in that place are many situations when this matters


Check if JVM is 32 or 64 chip from Java program:
1)Since inwards 32 chip JVM maximum heap size inwards Java tin non locomote to a greater extent than than 4GB (theoretically) , if you lot tin larn JVM version from a script similar running coffee ascendence you lot tin bring dissimilar retentiveness configuration for your application. Also, if in that place is whatever specific JVM options which exclusively applicable to 64 chip JVM than you lot tin laid those.

2)If your Java application is using native libraries as well as hence you lot surely desire to know whether Java running on the host is 32 chip or 64 chip because native library may bring dissimilar versions loaded for 32 chip or 64-bit architectures.

I am sure in that place could me approximately to a greater extent than practical reasons when you lot similar to find JVM chip size or whether JVM is 64 chip or not

Now let's come upward to mo role how to detect if JVM is 32 chip or 64 chip inwards Java.


How to cheque if JVM is 32 or 64 chip inwards host

 past times using either running coffee ascendence from the ascendence prompt or past times using  How to detect if JVM is 32 or 64 chip from Java program.As I said before in that place are 2 dissimilar approaches either using Java organization belongings similar "sun.arch.data.model" or "os.arch" or past times running coffee ascendence from script as well as checking its output for sure characters to position whether JVM is 64 chip or not. let's meet example of dissimilar ways to detect if JVM is 32 chip or 64 bit:

1) By using System belongings sun.arch.data.model:
You tin detect whether your JVM is 32 chip or 64 chip past times calling System.getProperty("sun.arch.data.model") at to the lowest degree on Sun's hotspot JVM. I don't aspect this to locomote run on whatever other Vendor specific JVM simply since most of the programmer or projection uses Sun's hotspot JVM. this is an handy option. for 32 chip JVM "sun.arch.data.model" volition locomote 32 as well as for 64 chip JVM this would locomote 64. hither is an example:

System.out.println("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

2)By using System.getProperty("os.arch")
"os.arch" is approximately other System belongings which you lot tin work to detect whether installed JRE or JVM is 32 chip or 64 bit. past times refer it sounds that it volition render operating organization arch simply you lot tin all the same give it a try. Though I haven't tested on all dissimilar JVM, I bring read that it tin indeed render JVM Bitness.If you lot endeavour this on 64 chip machine as well as 32 chip JVM combination than delight allow us know what does it return. hither is what it returns inwards instance of 32 chip JVM:

System.out.println("JVM Bit size: " + System.getProperty("os.arch"));

JVM Bit size: x86 //on 32 chip JVM
JVM Bit size: amd64 //on 64 chip JVM

3)java -d64 -version
This is approximately other agency of finding whether installed JRE or JVM is 64 chip or non simply unfortunately, it
doesn't operate amongst all windows version similar Windows XP simply it industrial plant fine on Windows 7. So you lot still
use it on Windows7 Machine for finding JVM bitness.

4)java -version
Plain one-time java -version reveals information near JVM bitness exclusively if installed JRE is 64 bit, inwards case
of 32 chip JVM it doesn't render whatever information related to architecture simply inwards the instance of 64 chip JVM it
prints :
C:\>java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)

while inwards instance of 32 chip JVM it volition print
C:\> coffee -version
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)


That’s all on how to detect if JVM is 32 chip or 64 chip from Java program as well as ascendence prompt. As I said its peculiarly useful if you lot bring a dependency on native libraries which has a dissimilar fix for 32 chip or 64-bit architecture. Let me know if you lot bring approximately to a greater extent than ways to detect JVM is 64 chip or not, you lot tin too portion on which scenario you lot ask to know JVM bitness.

Further Learning
Java Memory Management
How to increase Heap size inwards Maven as well as ANT

0 Response to "How To Honor If Jvm Is 32 Or 64 Flake From Coffee Program."

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel