Can a .class file generated using a 32 bit java compiler be used on a 64 bit system with 64 bit JVM?
Can a .class file generated using a 32 bit java compiler be used on a 64 bit system with 64 bit JVM?
-
4possible duplicate of [Java 32-bit vs 64-bit compatibility](http://stackoverflow.com/questions/783662/java-32-bit-vs-64-bit-compatibility) – stacker Jan 24 '11 at 09:50
-
@user518796: yes but only as long as the 32 bit .class ain't for a Java more recent than the 64-bit JVM. Create a .class with Java 6 / 32-bit and try to run it on a 64-bit Java 5 VM and Kaboom! (this has nothing to do with 32/64 bits but it is worth mentionning). – Gugussee Jan 24 '11 at 10:15
5 Answers
Yes. Java byte code is independent from 32/64/... bit systems.
That's the main purpose: the compiled code shall be executable on any system, just the virtual machine is compiled for a special system architecture.

- 113,398
- 19
- 180
- 268
-
is there any performance improvement over code compiled with 64 jdk vs 32 bit jdk (runtime is on 64 bit). – jay Mar 09 '16 at 05:35
Yes, bytecode is still very high level. There is no distinction between 32 and 64 bit at that level, just as there is no 32 and 64 bit Java code (.java).

- 163
- 1
- 5
Yes, the 64 bit VM's main difference is access to a larger maximum amount of memory.
The whole point of Java is that the compiled .class files work on any Java system, no matter the underlying hardware.
Your program will work on both a 32 bit and 64 bit system, but, if necessary, provided the hardware and OS is up to the job, your app will be able to access much more memory when running in a 64 bit VM compared with a 32 bit VM.

- 15,602
- 15
- 79
- 126
Yes, The compiled bytecode is the same between both versions of Java compilers

- 3,832
- 2
- 14
- 6
byte code, as the name suggests use byte based instructions, if anything byte code is more 8-bit centric. You should expect the 32-bit compiler and 64-bit compiler to produce the same code.
The only difference between the compilers is what is the native bit size for JVM which runs the compiler when it compiles. You shouldn't expect either to perform very differentl except the 64-bit version will not run on a 32-bit OS.

- 525,659
- 79
- 751
- 1,130
-
1Byte code is not "8-bit centric" because of the word "byte" (what does that even mean?). Java has integer types `int` and `long` that are always 32 and 64 bits, independent of the underlying operating system. – Jesper Jan 24 '11 at 10:00
-
1Like a I said the *instructions* are byte based. The instructions are a multiple of a byte in size. The most common ones are a byte in length. The 8086 supported 32-bit values long before 80386 was considered the first 32-bit processor in that family. – Peter Lawrey Jan 24 '11 at 10:14
-
Any suggestions on how I could clarify it. Pointing out the only bitness in byte code is byte centric instructions as the name suggests. I assume most people don't think it means anything when if you look at the design it does. – Peter Lawrey Jan 24 '11 at 13:12