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

2022-01-16 00:00:00 jvm eclipse-plugin java eclipse-rcp swt

我正在尝试调试此问题,但不确定我需要在哪里为 Eclipse替换 SWT jar 文件.

当前系统配置:

Eclipse Helios 3.6 - 32 位JDK 1.6JVM - 32 位视窗 7 - 64 位

错误信息:

java.lang.UnsatisfiedLinkError: 无法在 32 位 JVM 上加载 64 位 SWT 库在 org.eclipse.swt.internal.Library.loadLibrary(Library.java:194)在 org.eclipse.swt.internal.Library.loadLibrary(Library.java:174)在 org.eclipse.swt.internal.C.<clinit>(C.java:21)在 org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)在 org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:687)在 org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:161)在 de.vogella.rcp.intro.first.Application.start(Application.java:18)在 org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)在 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)在 org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)在 org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)在 org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)在 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)在 sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)在 java.lang.reflect.Method.invoke(Method.java:597)在 org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)在 org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)在 org.eclipse.equinox.launcher.Main.run(Main.java:1408)在 org.eclipse.equinox.launcher.Main.main(Main.java:1384)发生了错误.看看日志文件

解决方法:

  1. :建议了替代解决方案,但无法解决问题.

    还是一样的错误

  2. 我真的不想卸载 32-JVM 和 32-Bit Eclipse 并安装相应的 64 位版本.

    不是选项

paulsm4 和 Paul Webster 响应后的解决方法 &我很困惑

当我尝试执行此命令以检查 Eclipse 中的 JVM、JRE 版本时

package javaVersion;公共类 JavaVersion{公共静态无效主要(字符串[] args){System.out.println("JRE 版本:" + System.getProperty("java.runtime.version"));System.out.println("JVM 位大小:" + System.getProperty("sun.arch.data.model"));}}

输出:

1.6.0_31-b05JVM 位大小:32

但是当我在命令行上尝试 JAVA - VERSION

所以我的理解系统有 64 位 JVM,而 Eclispe 正在读取 32 位 JVM.那么如何转移系统读取 32 位 JVM 呢?

解决方案

Eclipse 正在使用您在启动配置中定义的任何 JRE 启动您的应用程序.由于您正在运行 32 位 Eclipse,因此您正在运行/调试其 32 位 SWT 库,并且您需要运行 32 位 JRE.

无论出于何种原因,您的 64 位 JRE 都是您的默认已安装 JRE.

要更改此设置,首先确保您在已安装的 JRE 首选项中配置了 32 位 JRE.转到 Window -> Preferences 并导航到 Java -> Installed JREs:

您可以单击添加并导航到您的 32 位 JVM 的 JAVA_HOME 以添加它.

然后在您的运行配置中,找到您的 Eclipse 应用程序并确保将运行时 JRE 设置为您刚刚配置的 32 位 JRE:

(请注意未突出显示的组合框.)

不要尝试替换 SWT jar,那样可能会很糟糕.

I'm trying to debug this problem but not sure where exactly i need to replace SWT jar file for Eclipse.

Current System Config:

Eclipse Helios 3.6 - 32 Bit
JDK 1.6 
JVM - 32 Bit 
Windows 7 - 64 Bit

Error Message:

java.lang.UnsatisfiedLinkError: Cannot load 64-bit SWT libraries on 32-bit JVM
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:194)
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:174)
    at org.eclipse.swt.internal.C.<clinit>(C.java:21)
    at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)
    at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:687)
    at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:161)
    at de.vogella.rcp.intro.first.Application.start(Application.java:18)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
An error has occurred. See the log file

Workaround:

  1. Link1: Understood the cause of the problem and i tried to replace 64-bit SWT to 32 Bit but i'm not sure whether i'm doing it right ?

    downloaded 32-bit file swt-3.6.1-win32-win32-x86.zip Extracted the zip file Have files as shown below

    copied swt.jar file navigated to C:Program Fileseclipseplugins removed 64-bit Swt file ( i.e org.eclipse.swt.win32.win32.x86_64.source_3.6.2.v3659c ) placed copied swt.jar file and relaunched

    Still throws SAME ERROR

    also tried renaming the swt.jar file to org.eclipse.swt.win32.win32.x86_64.source_3.6.2.v3659c

    Still same ERROR

  2. Link2: Suggested the alternative solution but couldn't resolve the problem.

    Still same ERROR

  3. I really don't want to uninstall 32-JVM and 32-Bit Eclipse and install corresponding 64 Bit versions.

    Not an OPTION

Workaround After the paulsm4 and Paul Webster response & i'm confused

When i tried executing this to check JVM, JRE version in Eclipse

package javaVersion;

public class JavaVersion
{

    public static void main( String[] args )
    {
        System.out.println( "JRE Version :" + System.getProperty( "java.runtime.version" ) );
        System.out.println( "JVM Bit size: " + System.getProperty( "sun.arch.data.model" ) );

    }

}

Output:

1.6.0_31-b05
JVM Bit size: 32

However when i tried on command line for JAVA - VERSION

So my understanding system has 64bit JVM where as Eclispe is reading 32 Bit JVM. So how can i divert system to read 32 Bit JVM ?

解决方案

Eclipse is launching your application with whatever JRE you defined in your launch configuration. Since you're running the 32-bit Eclipse, you're running/debugging against its 32-bit SWT libraries, and you'll need to run a 32-bit JRE.

Your 64-bit JRE is, for whatever reason, your default Installed JRE.

To change this, first make sure you have a 32-bit JRE configured in the Installed JREs preference. Go to Window -> Preferences and navigate to Java -> Installed JREs:

You can click Add and navigate to your 32-bit JVM's JAVA_HOME to add it.

Then in your Run Configuration, find your Eclipse Application and make sure the Runtime JRE is set to the 32-bit JRE you just configured:

(Note the combobox that is poorly highlighted.)

Don't try replacing SWT jars, that will likely end poorly.

相关文章