0

I use ghost4j GhostScript to convert PDF to TIF files in a Java Standalone Application.

I included Ghost4J into my project using Maven and installed Ghostscript (Windows) into C:\Program Files\gs... I tested the code in Window's everything worked fine. Life's good.

When I test the same application in Linux, it's not working expected. Gave me the below error.

Exception in thread "ForkJoinPool-1-worker-4" Exception in thread "ForkJoinPool-1-worker-24" Exception in thread "ForkJoinPool-1-worker-25" java.lang.NoClassDefFoundError: Could not initialize class org.ghost4j.GhostscriptLibrary
    at org.ghost4j.Ghostscript.initialize(Ghostscript.java:323)

I went through the code again, I am adding the GS libraries to the library path and the able to create the GhostScript instance

System.setProperty("jna.library.path", "C:\\Program Files\\gs\\gs9.19\\bin");
     Ghostscript gs = Ghostscript.getInstance();
     synchronized (gs) {
                gs.initialize(gsArgs);
                gs.exit();
            }

When running the Linux machine, I am passing gs-919-linux_x86_64 this executable.

Did anyone faced this issue when running Ghostscript in Linux machine ? B.T.W I did not install GhostScript in Linux.

Amedee Van Gasse
  • 7,280
  • 5
  • 55
  • 101
Venkat
  • 73
  • 3
  • 12
  • 1
    Why did you use the "itext" and "pdfbox" labels? – Tilman Hausherr Oct 06 '17 at 20:08
  • Tags deleted. The only remote connection with iText is that it uses Ghostscript in its tests, but that is native Ghostscript, not the ghost4j wrapper, because it also has to work in iText for .NET. – Amedee Van Gasse Oct 06 '17 at 20:18
  • Also, installing a wrapper for Ghostscript, but not installing Ghostscript itself, I am not sure how that is ever going to work. – Amedee Van Gasse Oct 06 '17 at 20:19
  • @AmedeeVanGasse You can execute the GhostScript command using the ProcessBuilder or Runtime rt = Runtime.getRuntime().exec(GSCOMMAND). By any chance did you work on GhostScript for a Java application ? – Venkat Oct 06 '17 at 20:34
  • I already answered that question in my first comment. – Amedee Van Gasse Oct 06 '17 at 20:41
  • See also [Why am I getting a NoClassDefFoundError in Java?](https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java) – Tilman Hausherr Oct 07 '17 at 10:23

0 Answers0