Java 无法在 64 位 JVM 上加载 32 位 SWT 库

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

Cannot load 32-bit SWT libraries on 64-bit JVM

javajvmswtlibraries

提问by sophia2046234

My computer is win7 64 bit, and jdk is 1.7.0.21,jvm is 1.6.. and 64 bit I want to run SWT application and export as runnable jar file. When I run the application, it has the exception that Cannot load 32-bit SWT libraries on 64-bit JVM, so I import the SDK as alternate jre just like you point at Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file ), and in Eclipse, the application can run correctly, but when I edit the bat file to run the jar file, it always has the problem like Cannot load 32-bit SWT libraries on 64-bit JVM, I have the swt.jar for 64 bit, but I don't konw how to replace and I wanna edit the bat file with the information with the SDK. How to handle the problem?

我的电脑是 win7 64 位,jdk 是 1.7.0.21,jvm 是 1.6.. 和 64 位我想运行 SWT 应用程序并导出为可运行的 jar 文件。当我运行应用程序时,它有一个例外,即无法在 64 位 JVM 上加载 32 位 SWT 库,因此我将 SDK 作为备用 jre 导入,就像您指向 无法在 32 位 JVM 上加载 64 位 SWT 库一样(替换 SWT 文件 ),并且在 Eclipse 中,应用程序可以正常运行,但是当我编辑 bat 文件以运行 jar 文件时,它总是出现无法在 64 位 JVM 上加载 32 位 SWT 库的问题,我有swt.jar 为 64 位,但我不知道如何替换,我想用 SDK 的信息编辑 bat 文件。如何处理问题?

回答by Andrew Martin

You have a 64bit JVM so it won't run the 32-bit SWT libraries. You need to either:

您有一个 64 位 JVM,因此它不会运行 32 位 SWT 库。您需要:

  1. Download and install the 32bit JVM and change your project's settings to run the 32bit JVM instead of the 64bit one.
  2. Download and install the 64bit libraries instead.
  1. 下载并安装 32 位 JVM 并更改项目的设置以运行 32 位 JVM 而不是 64 位 JVM。
  2. 下载并安装 64 位库。

This previous SO question has a great description of the first option with accompanying diagrams:

上一个 SO 问题对第一个选项进行了很好的描述,并附有图表:

Cannot load 64-bit SWT libraries on 32-bit JVM ( replacing SWT file )

无法在 32 位 JVM 上加载 64 位 SWT 库(替换 SWT 文件)

回答by guokai

64-bit JVM ? you should use the 64-bit swt

64 位 JVM ? 你应该使用 64 位 swt

回答by sunnyboy

Apart from the appropriate swt lib corresponding to the Operating system and their bitness, sometimes consider the following also:

除了与操作系统及其位数相对应的适当 swt 库外,有时还要考虑以下事项:

My environment:

我的环境:

32 bit Ubuntu

32 位 Ubuntu

32 bit JVM/JRE

32 位 JVM/JRE

Eclipse running using the 32 bit JRE

使用 32 位 JRE 运行的 Eclipse

32 bit Gtk SWT

32 位 Gtk SWT

Approach 1: I faced the problem when I was replacing the 32 bit swt with 64 bit swt to test on other platforms. To resolve, I had to remove/clean the project and rebuild the project with the 64 bit swt. But this step logically does not make sense, still works.

方法一:当我用 64 位 swt 替换 32 位 swt 以在其他平台上进行测试时,我遇到了这个问题。要解决此问题,我必须删除/清理项目并使用 64 位 swt 重建项目。但是这一步在逻辑上没有意义,仍然有效。

Approach 2: All my swt libs for each O/S had the same name- "swt.jar" residing in different folders. I only changed to the appropriate lib when testing, i.e., 32 and 64 bit o/s both has swt.jar. Now this was somehow causing some problem. Not yet able to identify. But on changing the name to something different for each of the swt lib files, it got resolved. This step also does not make much sense.

方法 2:我的每个操作系统的所有 swt 库都具有相同的名称 - “swt.jar”驻留在不同的文件夹中。我只是在测试的时候换了合适的lib,即32位和64位的o/s都有swt.jar。现在这以某种方式引起了一些问题。还不能鉴定。但是在将每个 swt lib 文件的名称更改为不同的名称时,它得到了解决。这一步也没有多大意义。

Approach 3: I am working using geotools api version 10.5 which also contains an swt library in the bin folder. I had to remove it from the folder (move to alternate location) and now my app runs smooth!!

方法 3:我正在使用 geotools api 版本 10.5,它也在 bin 文件夹中包含一个 swt 库。我不得不将它从文件夹中删除(移动到备用位置),现在我的应用程序运行流畅!!

回答by Ratish

I had a similar issue. Installing 32-bit jvm on my 64-bit machine solved the issue.

我有一个类似的问题。在我的 64 位机器上安装 32 位 jvm 解决了这个问题。

回答by Wender

My dificult to work with SWT is the distribution. It's require a installation for each SO (Linux, Windows | 32, 64), Swing no have this problem and is cool, but I prefer SWT/JFace.

我使用 SWT 的困难在于发行版。每个 SO(Linux、Windows | 32、64)都需要安装,Swing 没有这个问题并且很酷,但我更喜欢 SWT/JFace。

To solve this problem I create a Ant script to zip each installation with its rightful swt jar.

为了解决这个问题,我创建了一个 Ant 脚本来使用其合法的 swt jar 压缩每个安装。

I get the specific swt jars in:

我得到了特定的 swt 罐子:

http://archive.eclipse.org/eclipse/downloads/drops/R-3.6.1-201009090800/index.php#SWT

http://archive.eclipse.org/eclipse/downloads/drops/R-3.6.1-201009090800/index.php#SWT