我可以运行使用 32 位 jdk 和 64 位 jre 开发的 java 程序吗?应用程序使用 32 位非 java 系统库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13079991/
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-10-31 11:24:52  来源:igfitidea点击:

Can I run a java program developed using 32 bit jdk with 64 bit jre? application uses 32 bit non java system libraries

java64-bitjpcap

提问by schinoy

I am developing a java application using 64 bit eclipse on a 64 bit Windows 7 install. I'm forced to use a 32 bit JDK(1.7.0) because the application uses Jpcap, which wont compile with a 64 bit JDK.

我正在 64 位 Windows 7 安装上使用 64 位 eclipse 开发 Java 应用程序。我被迫使用 32 位 JDK(1.7.0),因为该应用程序使用Jpcap,它不会使用 64 位 JDK 进行编译。

The application has to be cross platform across 32 bit and 64 bit systems, which is normally the case with java applications developed using any JDK. But I believe the situation is slightly complicated because besides a jar, Jpcap installs system libraries (.dll/.so) which in turn are wrappers for WinPcap and libpcap. So a Jpcap call is a succession of nested invocations to these libraries.

应用程序必须是跨 32 位和 64 位系统的跨平台,这通常是使用任何 JDK 开发的 Java 应用程序的情况。但我认为情况有点复杂,因为除了 jar 之外,Jpcap 还安装了系统库 (.dll/.so),而这些库又是 WinPcap 和 libpcap 的包装器。因此,Jpcap 调用是对这些库的一系列嵌套调用。

Here's the question:

这是问题:

Will the application executable work on 64 bit platforms? assuming users will have the required x86 libraries installed (jpcap.dll/.so, WinPcap, libpcap) as 64 bit versions do not exist for the windows libs.

应用程序可执行文件能否在 64 位平台上运行?假设用户将安装所需的 x86 库(jpcap.dll/.so、WinPcap、libpcap),因为 Windows 库不存在 64 位版本。

采纳答案by Stephen C

Will the application executable work on 64 bit platforms? assuming users will have the required x86 libraries installed (jpcap.dll/.so, WinPcap, libpcap) as 64 bit versions do not exist for the windows libs.

应用程序可执行文件能否在 64 位平台上运行?假设用户将安装所需的 x86 库(jpcap.dll/.so、WinPcap、libpcap),因为 Windows 库不存在 64 位版本。

You will need to use a 32-bit JRE to run the application. A 64-bit Hotspot JRE cannot use 32-bit native libraries.

您将需要使用 32 位 JRE 来运行该应用程序。64 位热点 JRE 不能使用 32 位本机库。

But the flipside is that it doesn't matter if you use a 64-bit or 32-bit Eclipse for developing and building ... provided that you configure Eclipse to launch a 32-bit JRE for any testing that involves the native libraries.

但另一方面,如果您使用 64 位或 32 位 Eclipse 进行开发和构建并不重要……只要您将 Eclipse 配置为启动 32 位 JRE 以进行任何涉及本机库的测试。

And to be clear, you can run a 32-bit JRE on a 64-bit OS platform, but not the other way around.

需要明确的是,您可以在 64 位操作系统平台上运行 32 位 JRE,但反过来不行。



UPDATE- apparently the jpcap.dll canbe built for 64-bit Windows - see this posting: https://groups.google.com/forum/?fromgroups=#!topic/jpcap/-vxZv0eAcp4

更新- 显然 jpcap.dll可以为 64 位 Windows 构建 - 请参阅此帖子:https: //groups.google.com/forum/?fromgroups=#!topic/jpcap/-vxZv0eAcp4

回答by MadProgrammer

From memory (and it's a little foggy) I'd so no.

根据记忆(而且有点模糊)我不会。

Native libraries (at least under windows) need to be executed within the same bit beepthness as the JVM.

本机库(至少在 Windows 下)需要在与 JVM 相同的位深度内执行。

So, in order for you to be able to load your x32 bit libraries, you should be running within a x32 bit process (or x32 bit JVM)

因此,为了能够加载 x32 位库,您应该在 x32 位进程(或 x32 位 JVM)中运行