It's not a secret anymore!
The moose likes General Computing and the fly likes 32 bit JRE vs 64 bit JRE Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » General Computing
Bookmark "32 bit JRE vs 64 bit JRE" Watch "32 bit JRE vs 64 bit JRE" New topic
Forums: Java in General General Computing

32 bit JRE vs 64 bit JRE

Ronald James

Joined: Oct 17, 2013
Posts: 4
We have an unsupported 3rd party reporting application, (Panscopic’s Scopeserver running under Tomcat), that has started having out of memory errors when running very large reports. Long term, we’re looking for a replacement, but short term I’m wondering if I can upgrade the underlying Java run-time environment to 64 bit. We’re currently running under a 32 bit version of Java on 64 bit MS Windows with 12Gb RAM.
Given that Java compiles to byte-code and the run time environment enables that code to run on a variety of platforms,
• Will Java .class files compiled under a 32 bit version of the compiler run under a 64 bit version of the run time environment?
• If the software runs, is it likely that Out-Of-Memory problems might go away, at least until we hit 64 bit limits?
Martin Vajsar

Joined: Aug 22, 2010
Posts: 3733

Welcome to CodeRanch, Ronald!

Unless your application uses some native code (eg. via JNA or JNI), the Java application should run the same on the 32 bit and 64 bit JREs. You definitely can use the same .class or .jar files.

You won't hit any 64 bit limit any time soon. You might, however, find out that when run on the 64 bit JRE the application uses more memory, the reason is that the pointers Java internally uses take more memory - theoretically 64 bits instead of 32, but the JRE might perform some operations to shrink the pointer size (at the price of some small performance hit). It would be a good idea to run some tests before you make this change in production.
Rob Spoor

Joined: Oct 27, 2005
Posts: 20271

With a 32-bit JRE, the Java heap space is limited to around 1.5GB (by Windows, this limit exists for all 32-bit applications). With a 64-bit JRE this limit does not exist, so you can use -Xmx to allow Java to use more memory than that 1.5GB. (At work, we've used up to 14GB without any problems.)

How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

Ronald James wrote:• Will Java .class files compiled under a 32 bit version of the compiler run under a 64 bit version of the run time environment?

There is no difference in the bytecode produced by the Java compiler included in the 32-bit JDK and in the 64-bit JDK. Java bytecode is not 32-bit or 64-bit, like native code. (Since the Java compiler itself is written mostly in Java, it's in fact the exact same compiler). It doesn't matter if you compile your code on a 32-bit or 64-bit JDK - it will run on any JVM.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: 32 bit JRE vs 64 bit JRE
jQuery in Action, 3rd edition