使用 Eclipse 在 64 位机器上编译 32 位 Java

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17145781/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 20:44:57  来源:igfitidea点击:

Compile 32 bit Java builds on 64 bit machine with Eclipse

javaeclipsebuild64-bit32-bit

提问by Arturas M

so the questions as in the title, I need to run my server application in Tomcat on a System which is 32 bit Windows XP, I am working and compiling on my 64 bit Windows 7 in Eclipse. How do I compile it to 32 bit, what do I need to do? I assume it won't work on the 32 bit Windows when I'm compiling it on a 64 bit machine?

所以标题中的问题,我需要在 32 位 Windows XP 系统上的 Tomcat 中运行我的服务器应用程序,我正在 Eclipse 中的 64 位 Windows 7 上工作和编译。如何将其编译为 32 位,我需要做什么?当我在 64 位机器上编译它时,我认为它不能在 32 位 Windows 上工作?

回答by Juned Ahsan

Java doesn't build 32-bit or 64-bit applications - bytecode is portable across different bit architectures.

Java 不构建 32 位或 64 位应用程序 - 字节码可以跨不同位架构移植。

The only exception is native libraries that you might be using in your code. If there are any then you will have to manually compile those for the respective platform. Otherwise the java code is totally portable across 32-bit and 64-bit platforms.

唯一的例外是您可能在代码中使用的本机库。如果有,那么您将不得不为相应的平台手动编译它们。否则,java 代码在 32 位和 64 位平台上是完全可移植的。

回答by Peter Tseng

The problem is your JNI DLL, which needs to be compiled for 32-bit to match the 32-bit JRE.

问题在于您的 JNI DLL,它需要针对 32 位编译以匹配 32 位 JRE。

回答by Warley Noleto

You could install a 32bits jdk on a 64bits machine. point the JAVA_HOME to this jdk and use it. It

您可以在 64 位机器上安装 32 位 jdk。将 JAVA_HOME 指向这个 jdk 并使用它。它

回答by Uwe Plonus

Java is independent of the OS.

Java 独立于操作系统。

You can compile with your 64bit machine and run this on a 32bit computer as long as this computer has a 32bit VM.

你可以用你的 64 位机器编译并在 32 位计算机上运行它,只要这台计算机有 32 位虚拟机。

回答by DusteD

If you're still searching for some "simple" solution, one would be to install a 32 bit os in a virtual machine and run eclipse from there.. Very ugly I know, but it works.

如果您仍在寻找一些“简单”的解决方案,一个方法是在虚拟机中安装 32 位操作系统并从那里运行 eclipse.. 我知道非常丑陋,但它有效。

Another approach is mentioned here. How to launch java swing app which used precompled DLL from cmd?

这里提到了另一种方法。如何从 cmd 启动使用预编译 DLL 的 java swing 应用程序?