Java Jar 在 Linux 上寻找 Windows SWT 库

huangapple go评论75阅读模式
英文:

Java Jar Looking for Windows SWT Library on Linux

问题

一年前,我创建了一个在Windows上开发并部署到Linux的Eclipse项目。我使用了SWT,并且通过适当的SWT jar包在Linux上成功运行它。没有问题。

最近,我开始了一个新项目,采用了相同的方法:在Windows上开发,部署到Linux,使用SWT。我使用了与之前成功项目相同的项目结构,但它无法在Linux上运行。当我尝试在Linux上运行新项目时,它抛出了一个UnsatisfiedLinkError错误:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 无法加载SWT库。原因:
java.library.path中没有swt-win32-4924r25
java.library.path中没有swt-win32
无法加载库:/home/hmartin/.swt/lib/linux/x86_64/libswt-win32-4924r25.so
无法加载库:/home/hmartin/.swt/lib/linux/x86_64/libswt-win32.so

我觉得奇怪的是,它似乎在寻找Windows版本的SWT jar包,我不明白为什么会这样。我已经尝试过更改项目首选项、构建路径、build.xml、清单文件等。

我有一个清单文件,应该告诉应用程序其SWT库的位置(与应用程序jar包相同的目录),但我怀疑我的项目并不知道它的存在。在一年前制作的可工作项目中,我记得能够让Eclipse在导出时生成一个清单文件,那就是我所做的。但在这个(有问题的)项目中,我无法生成清单文件,也不能在导出时从工作区选择清单文件。这次,我只是自己创建了一个清单文件,遵循了命名约定,然后希望奇迹会发生。但奇迹并没有发生。

非常感谢您提供帮助、建议、推荐等。

英文:

A year ago, I created an Eclipse project that was developed on Windows and deployed to Linux. I used SWT, and I was able to get it running on Linux with the appropriate SWT jar. No problems.

Recently, I started a new project with the same MO: develop on Windows, deploy to Linux, use SWT. I used the same project structure as the project that worked, but it won't work on Linux. When I try to run the new project on Linux, it hits me with an UnsatisfiedLinkError:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-win32-4924r25 in java.library.path
no swt-win32 in java.library.path
Can't load library: /home/hmartin/.swt/lib/linux/x86_64/libswt-win32-4924r25.so
Can't load library: /home/hmartin/.swt/lib/linux/x86_64/libswt-win32.so

What looks peculiar to me is that it seems to be looking for the Windows version of the SWT jar, and I don't understand why that could be. I've fiddled with project preferences, build paths, build.xml, manifests, etc.

I do have a manifest that is supposed to tell the application where its SWT library is (in the same directory as the application jar), but I suspect that my project doesn't know it exists. With the working project I made a year ago, I remember being able to have Eclipse generate a manifest file upon export, and that's what I did. With this (broken) project, I am not able to generate a manifest file nor do I have the option of selecting one from the workspace upon export. This time, I just made a manifest file myself, followed the naming conventions, and hoped the magic happened. The magic has not happened.

Help, suggestions, recommendations, etc. are much appreciated.

答案1

得分: 0

玩弄了一个测试项目和导出设置之后,我发现问题的原因是JAR导出界面上的一个复选框:“导出生成的类文件和资源”。我之前没有勾选这个框,这意味着(出于某种原因)Eclipse不会显示给我生成或选择清单的选项。勾选了该复选框并选择了清单后,新项目现在可以在目标平台上运行。

英文:

After playing around with a test project and export settings, I discovered that the cause of my problems was one single check box on the JAR export screen: "Export generated class files and resources". I had this box unchecked, which meant that (for some reason) Eclipse wouldn't show me the options to generate or select a manifest. With that box checked and manifest selected, the new project now runs on the target platform.

huangapple
  • 本文由 发表于 2020年9月1日 02:23:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/63676186.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定