Reputation: 21
I am trying to install Ghostscript on my Linux server so that Ghost4j's PDF Utilities can be used.
I installed Ghostscript with LinuxBrew and added the path to Ghostscript binary to $PATH. So after this point, I was getting the following error:
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)
At this step, it was able to load and execute to GhostscriptLibrary.
After doing some research, I added symlink ln -s path/to/Ghostscript/lib/libgs.so.9.22 /usr/lib/libgs.so
following this thread Unable to load library 'gs': libgs.so: cannot open shared object file: No such file or directory and this resolved the previous error but gave another error:
java.lang.NoClassDefFoundError: Could not initialize class org.ghost4j.GhostscriptLibrary at
org.ghost4j.Ghostscript.initialize(Ghostscript.java:323)
The jar file (ghost4j-1.0.1.jar) containing the class GhostscriptLibrary is in the classpath and it works completely fine locally on my Mac.
I am using Ghostscript 9.22 and Ghost4j 1.0.1
Any help would be great :)
Upvotes: 1
Views: 4247
Reputation: 21
I was able to resolve the above error by uninstalling Ghostscript and reinstalling it with the instructions on this page http://www.linuxfromscratch.org/blfs/view/svn/pst/gs.html and set the environment variable LD_LIBRARY_PATH to include the path to the .so files.
It was an issue with not being about to correctly load the native library, which was causing the second error regardlessly.
Upvotes: 1