• Post Reply Bookmark Topic Watch Topic
  • New Topic

64 bit applications  RSS feed

 
Dhinesh babu
Greenhorn
Posts: 15
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

If i develop an application in Java, How can i know whether it is 64 bit or for 32 bit OS ?

Thanks in advance,
Dhinesh
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You normally don't need to know. Java applications are independent of the "bitness" of the operating system. You don't need to do anything to make your application to run on a 32-bit or 64-bit operating system.

If you really want to know, you can look at the "os.arch" system property:

On the system which I'm using right now, which has 32-bit Windows Vista, it says "x86". I guess that for a 64-bit Windows system it would say "x86-64" or something similar.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sun has a Java System property to determine the bitness of the JVM: 32 or 64:

sun.arch.data.model=32 // 32 bit JVM
sun.arch.data.model=64 // 64 bit JVM

You can use

System.getProperty("sun.arch.data.model")

to determine if its 32/64 from the program.

From the sun.docs:

When writing Java code, how do I distinguish between 32 and 64-bit operation?

There's no public API that allows you to distinguish between 32 and 64-bit operation. Think of 64-bit as just another platform in the write once, run anywhere tradition. However, if you'd like to write code which is platform specific (shame on you), the system property sun.arch.data.model has the value "32", "64", or "unknown".

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16057
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But note that sun.arch.data.model is a Sun-specific system property; it's not part of the official public Java API and it will most likely not exist on JVM implementations from different vendors.
 
Ove Lindström
Ranch Hand
Posts: 326
Android Firefox Browser Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point Jesper.

IBM use com.ibm.vm.bitmode.

So with all this info, it is possible to write a DetectJVM class. (or google it).
 
Dhinesh babu
Greenhorn
Posts: 15
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks folks,

I got it, and am really proud to be a part of Ranch.

 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ove Lindström wrote: . . . So with all this info, it is possible to write a DetectJVM class. (or google it).
I recommend you Google it. It took me two minutes to write and execute. Life's too short waste two minutes.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!