在Mac OS X上使用sqlite4java Jar的UnsatisfiedLinkError [英] UnsatisfiedLinkError with sqlite4java Jar on Mac OS X

查看:111
本文介绍了在Mac OS X上使用sqlite4java Jar的UnsatisfiedLinkError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Java应用程序中使用sqlite4java库,当我在Eclipse中运行它时,它运行得很好。但是当我构建可运行的JAR并尝试在Mac OS X上运行它时,我收到以下错误:

I'm using the sqlite4java library in my Java application and it works just fine when I'm running it in Eclipse. But when I build the runnable JAR and try to run it on Mac OS X, I get the following error:

Error: Could not load database file. 
Error: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library:
java.lang.UnsatisfiedLinkError: no sqlite4java-osx-x86_64 in java.library.path

即使我选择将所需的库打包到生成的JAR中,也会发生这种情况,这应该会复制我需要的所有文件。为什么这不起作用?

This happens even when I select "Package required libraries into generated JAR", which supposedly copies over all of the files I need. Why isn't this working?

推荐答案

与许多其他依赖项不同,sqlite4java使用基于主机平台的其他文件与SQLite进行交互数据库。当Eclipse打包所需的库时,它只复制sqlite4java.jar文件,而不复制其他所需的文件。

Unlike many other dependencies, sqlite4java uses additional files based on the host platform to interface with SQLite databases. When Eclipse packages the required libraries, it only copies the sqlite4java.jar file, but not the other required files.

您可能认为解决方案是导出runnable JAR文件的选项将所需的库复制到生成的JAR旁边的子文件夹中并手动添加丢失的文件,但是,这似乎也不起作用。

You might think that the solution would be to export the runnable JAR file with the option "Copy required libraries into a sub-folder next to the generated JAR" and manually add the missing files, but alas, that doesn't seem to work either.

我发现的最佳解决方案实际上是最适合Mac的解决方案。您可以导出为Mac OS X应用程序包,而不是导出为可运行的JAR文件!要在Eclipse中执行此操作:

The best solution I've found is actually the most Mac-friendly one. Instead of exporting as a runnable JAR file, you export as a Mac OS X application bundle! To do that in Eclipse:


  1. 转到文件 - >导出...

  2. 在其他文件夹下,选择Mac OS X应用程序包

  3. 填写第一个屏幕并单击下一步

  4. 在添加到Bundle部分,在添加到类路径部分的SQLite下载中添加libsqlite4java-osx.jnilib文件(如果你还可以添加libsqlite4java-osx-10.4.jnilib和libsqlite4java-osx-ppc.jnilib) '支持传统硬件)

  5. 点击完成

  1. Go to "File" –> "Export…"
  2. Under the "Other" folder, choose "Mac OS X application bundle"
  3. Fill out the first screen and click "Next"
  4. Under the "Add to Bundle" section, add the "libsqlite4java-osx.jnilib" file from your SQLite download in the "Add to Classpath" section (you can also add libsqlite4java-osx-10.4.jnilib and libsqlite4java-osx-ppc.jnilib if you're supporting legacy hardware)
  5. Click "Finish"

你现在有一个正确加载sqlite4java的Mac OS X应用程序。

You'll now have a Mac OS X application that properly loads sqlite4java.

这篇关于在Mac OS X上使用sqlite4java Jar的UnsatisfiedLinkError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆