在Mac下运行swt出错:java.lang.UnsatisfiedLinkError: no swtcarbon3346 or swtcarbon in swt.library.path, java.library.path or the jar file

Ok, the resources that you need to read are:

  • First, you need to read an awesome background article at Borderland Consulting
  • Then, you'll want the very cool Jar Bundler Ant Task which will put together an app bundle for you and copy all your jars into the right directory structure and create an Info.plist file for you
  • Then (and this bit just killed me), you must make sure that you chmod your .jnilib files executable! If you don't, you'll end up getting a "Could not load library" error even though the swt library is clearly in your java.library.path!
  • Finally, you must add an entry StartOnMainThread to your Info.plist file which resolved some Threading issues with the launcher. If you're getting weird GUI behaviour with disappearing buttons and bizarre crashes, it will probably be cause you've missed this setting.

   no swt-carbon-3346 or swt-carbon in  swt.library.path, java.library.path or the jar file 大意即,如果SWT应用程序用到了SWT组件,则还必须将SWT的本地化文件加入到JVM可以找到的路径中。方法有三个:
   1.修改每个工程运行时的运行VM参数,用-Djava.library.path={runtime-library-path}把本地化SWT库文件通知JVM。显然,这是指在Eclipse平台下运行,而且每个工程都要修改一次,很麻烦。
   2.在环境变量中设置库路径。对于Linux,就是修改LD_LIBRARY_PATH这个环境变量,让它指到本地化SWT库中。
   3.拷贝本地化SWT库文件到已经指定的Java库路径中。

原文地址:https://www.cnblogs.com/huqingyu/p/1382889.html