| Author |
Detect which kind of JRE is installed - 32 or 64 bit
|
Pranjal Nagar
Greenhorn
Joined: Mar 23, 2010
Posts: 6
|
|
|
I have an application where I ask the user to enter the path to a JRE. I need to detect if the JRE enetered by the user is a 32 or 64 bit JRE. Is there a way I can detect whether the JRE is a 32 or 64 bit one.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8439
|
|
|
You can check the value for System.getProperty("sun.arch.data.model") which will return either of 32, 64 or unknown
|
[Donate a pint, save a life!] [How to ask questions] [Onff-turn it on!]
|
 |
Pranjal Nagar
Greenhorn
Joined: Mar 23, 2010
Posts: 6
|
|
Can you help me with some code snippet?
How can I call this for a particular JRE? There could be a possibility that I have two JREs of different versions on my system.
|
 |
Maneesh Godbole
Saloon Keeper
Joined: Jul 26, 2007
Posts: 8439
|
|
I already gave you read made code
Do you know what System.property does? If not check the API docs.
Even if you have multiple jre versions, this call will give you the details for the jre currently being used to run your application.
Also, I am not sure if one can install a 32 bit jre/jdk on a 64 bit system and vice versa
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
Maneesh Godbole wrote:Also, I am not sure if one can install a 32 bit jre/jdk on a 64 bit system and vice versa
Yes you can, in fact I'm using a 32-bit JRE on 64-bit Windows right now. On Linux it's also possible to run 32-bit Java on a 64-bit Linux installation. (The reverse is not possible - you can't run 64-bit software on a 32-bit operating system).
But I'm not sure why your Java application needs to know if it's running on a 32-bit or 64-bit JRE - it should not matter what architecture the underlying operating system (or JRE itself) has for normal Java programs.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
 |
|
|
subject: Detect which kind of JRE is installed - 32 or 64 bit
|
|
|