java.lang.NoClassDefFoundError:无法初始化类org.ghost4j.GhostscriptLibrary

java.lang.NoClassDefFoundError:无法初始化类org.ghost4j.GhostscriptLibrary,java,ghost4j,Java,Ghost4j,我正在尝试在我的Linux服务器上安装Ghostscript,以便可以使用Ghost4j的PDF实用程序 我使用LinuxBrew安装了Ghostscript,并将Ghostscript二进制文件的路径添加到$path。因此,在这一点之后,我得到了以下错误: java.lang.UnsatisfiedLinkError: Unable to load library 'gs': Native library (linux-x86-64/libgs.so) not found in resourc

我正在尝试在我的Linux服务器上安装Ghostscript,以便可以使用Ghost4j的PDF实用程序

我使用LinuxBrew安装了Ghostscript,并将Ghostscript二进制文件的路径添加到$path。因此,在这一点之后,我得到了以下错误:

java.lang.UnsatisfiedLinkError: Unable to load library 'gs': Native library (linux-x86-64/libgs.so) not found in resource path 
at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:271)
at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:398)
at com.sun.jna.Library$Handler.<init>(Library.java:147)
at com.sun.jna.Native.loadLibrary(Native.java:412)
at com.sun.jna.Native.loadLibrary(Native.java:391)
at org.ghost4j.GhostscriptLibraryLoader.loadLibrary(GhostscriptLibraryLoader.java:39)
at org.ghost4j.GhostscriptLibrary.<clinit>(GhostscriptLibrary.java:36)
at org.ghost4j.Ghostscript.initialize(Ghostscript.java:323)
包含类GhostscriptLibrary的jar文件(ghost4j-1.0.1.jar)位于类路径中,在我的Mac上本地运行完全正常

我正在使用Ghostscript 9.22和Ghost4j 1.0.1


任何帮助都很好:)

我可以通过卸载Ghostscript并按照本页上的说明重新安装它来解决上述错误,并将环境变量LD_LIBRARY_PATH设置为包含.so文件的路径


这是一个无法正确加载本机库的问题,这导致了第二个错误

NoClassDefFoundError
的堆栈跟踪是否提供包装异常?在这里,我将首先查找失败原因的详细信息。如果没有更多信息,我们将在黑暗中拍摄。带有消息
NoClassDefFoundError
无法初始化类XYZ
,意味着JVM已经尝试对类
XYZ
执行静态初始化,但失败。在这种情况下,
GhostScriptLibrary
中唯一的静态初始化是加载本机库。请重新启动运行Java代码所用的任何程序,并查看代码引发的异常情况。@LukeWoodward是的,我认为加载本机库(使用jna)也有问题,因为我认为它在第一次加载库时没有正确加载,并给出“无法加载库”错误,然后再次运行它会产生第二个错误。
java.lang.NoClassDefFoundError: Could not initialize class org.ghost4j.GhostscriptLibrary at 
org.ghost4j.Ghostscript.initialize(Ghostscript.java:323)