Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Detect which kind of JRE is installed - 32 or 64 bit

 
Pranjal Nagar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can check the value for System.getProperty("sun.arch.data.model") which will return either of 32, 64 or unknown
 
Pranjal Nagar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11021
12
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 15214
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic