简体   繁体   English

Java在64位操作系统上编译32位操作系统运行时问题

[英]Java compiled on 32-bit OS runtime issues on 64-bit OS

运行在32位计算机上编译并在64位计算机上运行的Java应用程序是否存在已知问题?

The byte code generated by a 32-bit JDK is identical to the byte code generated by a 64-bit JDK. 由32位JDK生成的字节代码与由64位JDK生成的字节代码相同。 If you have a problem which only occurs on a 64-bit JVM, is because there is a bug in the JVM and using a 64-bit JDK wouldn't make any difference. 如果您遇到仅在64位JVM上出现的问题,那是因为JVM中存在错误并且使用64位JDK不会产生任何差异。

The idea behind Java is that the byte code version of a program is the same for all platforms. Java背后的想法是程序的字节码版本对于所有平台都是相同的。 This is why you can compile on a Windows machine and run the resulting class and jar files on a Linux box. 这就是为什么你可以在Windows机器上编译并在Linux机器上运行生成的类和jar文件的原因。 I do such cross compilation daily. 我每天都做这样的交叉编译。

This includes whether the JVM uses 32 or 64 bits. 这包括JVM是使用32位还是64位。

So, the simple answer is no, there is no issues 所以,简单的答案是否定的,没有问题

(the more advanced answer is that if you also use non-Java native code that you bring in with your Java code, like a DLL or so, then that code will most likely need to be recompiled) (更高级的答案是,如果您还使用Java代码引入的非Java本机代码,如DLL等,则很可能需要重新编译该代码)

It depends on your application, but under normal circumstances, there whould be no problem running code from an x86 machine on an x64 machine, and vice versa. 这取决于您的应用程序,但在正常情况下,从x64计算机上的x86计算机运行代码是没有问题的,反之亦然。

If you use plain old java (no interop, no call to native libraries), the generated bytecode will be machine-independant, and should run on any installed JVM. 如果使用普通的旧java(没有互操作,不调用本机库),生成的字节码将与机器无关,并且应该在任何已安装的JVM上运行。

None that I can think of unless you explicitly called 32 bit native code specific to an environment. 除非您明确调用特定于环境的32位本机代码,否则我无法想到。

Operating systems like windows use WoW64 to allow 32 bit apps to run under 64 bit systems. 像Windows这样的操作系统使用WoW64允许32位应用程序在64位系统下运行。 It is a provision that allows for backward compatibility. 它是一种允许向后兼容的规定。 As long as native libraries depend only on 32 bit or only on 64 bit libraries, everything is good. 只要本机库仅依赖于32位或仅依赖于64位库,一切都很好。 The JVM takes care of converting your byte code to the appropriate machine code using JIT so there should be no worries. JVM负责使用JIT将您的字节代码转换为适当的机器代码,因此不必担心。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM