zippy1978 / ghost4j

Java wrapper for Ghostscript C API + PS/PDF document handling API
http://www.ghost4j.org
GNU Lesser General Public License v3.0
64 stars 39 forks source link

DLL not found in Windows 7 64 bit #3

Closed jmkgreen closed 11 years ago

jmkgreen commented 11 years ago

On Windows 7 with GhostScript 9 installed via the installer package, ghost4j seems unable to resolve the DLL which is listed in the registry.

If I run a unit test in my code, no exception is thrown. Yet running my project within Tomcat we end up with an error saying that the temporary file could not be removed.

If I then take the DLL and place it within Windows, and restart Tomcat, all works well.

So it would be good to have some definitive way of checking for the DLL first (a dedicated exception would be preferred).

zippy1978 commented 11 years ago

Hi, If you want to check that Ghostscript shared library is visible to Java you can use the following code (to get info about the Ghostscript revision):

GhostscriptRevision revision = Ghostscript.getRevision();

If the exception java.lang.UnsatisfiedLinkError: Unable to load library is thrown, then the shared library cannot be found by Java / Ghost4J.

byersa commented 11 years ago

I think I am having a related problem. I hope it is ok to post it here; can't find a more suitable place.

I am running ghost4j-0.5.0 with ghostscript 9.0.2 on a 32-bit ubuntu 12.10 amazon instance. (I am thinking that I need to run 9.0.2 for legal reasons - it being the last GPL release.) I get the UnsatisfiedLinkError. I have gs in /usr/local/lib/gs and i put a symbolic link in /usr/bin

The error is: java.lang.UnsatisfiedLinkError: Unable to load library 'gs': com.sun.jna.Native.open(Ljava/lang/String;)J

It says nothing about shared libraries.

I have been poking around and I found something about building gs with the "so" option, so I tried it with: make XCFLAGS=-DHAVE_SYS_TIME_H=1 so and it built an sobin with libso libs in it, which were not there before (did i mention that I built gs from source) and copied the libgs/libgs.so.9/libgs.so.9.02 to /usr/lib but I got the same error. I ran "ldconfig" and fixed some symbolic link issues with the same result.

Is this a problem with versions? Do I have to use the latest ghostscript? go back 8.71? use an earlier ghost4j?

Thanks for any help.

byersa commented 11 years ago

sorry - I get the error when i run: GhostscriptRevision revision = Ghostscript.getRevision()

byersa commented 11 years ago

Sorry, I was running OpenJdk-7 instead of Oracle-7. When I switched to Oracle, that problem went away and I got an Out of memory error, but that is a different problem.

zippy1978 commented 11 years ago

Hi, So do you mean your problem is solved ? I admit I have never tested with OpenJDK...

byersa commented 11 years ago

Yes, merely changing from OpenJDK to Oracle 7 java made that problem go away. I tried a lot of things, but I only made that one change and then it worked.

I am getting an OutOfMemoryError in GhostScript line 493: byte[] data = getDisplayData().getPimage().getByteArray( but I guess that is a "gs" issue? It happens on certain pages and does not seem to be related to how much heapspace is available.

While I have your attention, can you tell me if I am correct in thinking that I can use GhostScript 9.02 on a server because it is GPL, but not later versions? Do you have any experience with negotiating a commercial license with Artiflex?

And thanks for Ghost4J.

Al Byers

On Mon, Feb 25, 2013 at 1:44 PM, Gilles Grousset notifications@github.comwrote:

Hi, So do you mean your problem is solved ? I admit I have never tested with OpenJDK...

— Reply to this email directly or view it on GitHubhttps://github.com/zippy1978/ghost4j/issues/3#issuecomment-14074382.

zippy1978 commented 11 years ago

Hi, Your OutOfMemoryError is probably raised because you don't have enough memory for your JVM. Working with byte array rasters takes a lot of memory...

I only work with GPL versions of Ghostscript, so I never had to contact Artiflex for commercial licences... However I think that the latest GPL version is 9.0.7.