I make a plugin for the application, on a ViewPart, a simple pdf viewing tool for converting to images. I chose ghost4j for conversion

org.ghost4j.document.PDFDocument document = new org.ghost4j.document.PDFDocument(); document.load(new File(sourceFile.getAbsolutePath())); org.ghost4j.renderer.SimpleRenderer renderer = new org.ghost4j.renderer.SimpleRenderer(); int dpi = 200; renderer.setResolution(dpi); List<Image> images = renderer.render(document); 

Mistake

java.lang.NoClassDefFoundError: org / ghost4j / document / Document

It appears as soon as I open my ViewPart. The problem is in the last line, without it the ViewPart opens without errors. Also, if I create a test project from the examples of ghost4j, then it works fine with the same code. The library added everything you need. In the classpath tried to add this jarnik, it did not help. I do not understand what the catch is.

  • one
    Most likely in ghost4j, one of the dependencies containing org.ghost4j.document.Document is marked as optional (so as not to inflate the size of the jarnica), which is why your build system does not pull it up automatically. After you explicitly declare it, everything should fall into place. - etki
  • corrected to org.ghost4j.document.PDFDocument document = new org.ghost4j.document.PDFDocument(); document.load(new File(sourceFile.getAbsolutePath())); org.ghost4j.document.Document doc = document.extract(1, document.getPageCount()); System.out.println("Total files to be converted -> "+ document.getPageCount()); org.ghost4j.renderer.SimpleRenderer renderer = new org.ghost4j.renderer.SimpleRenderer(); int dpi = 200; renderer.setResolution(dpi); images = renderer.render(doc); org.ghost4j.document.PDFDocument document = new org.ghost4j.document.PDFDocument(); document.load(new File(sourceFile.getAbsolutePath())); org.ghost4j.document.Document doc = document.extract(1, document.getPageCount()); System.out.println("Total files to be converted -> "+ document.getPageCount()); org.ghost4j.renderer.SimpleRenderer renderer = new org.ghost4j.renderer.SimpleRenderer(); int dpi = 200; renderer.setResolution(dpi); images = renderer.render(doc); ViewPart launches - Dmitriy
  • but when executing the function, the error in the first line ... java.lang.NoClassDefFoundError: org/ghost4j/document/PDFDocument - Dmitriy
  • is decided. a folder is created in the project, for example lib, in it we copy all external jar files. In the classpath (on the Runtime tab) we add lines of the form - lib / ghost4j-1.0.1.jar ... - Dmitriy
  • You can write it with the usual answer and then (after some time, the system provides a timeout) to accept it so that those who come here from the search engines can see your decision - etki

1 answer 1

Solved. A folder is created in the project, for example lib , we copy all external jar files into it. In the classpath (on the Runtime tab) add the lines of the form - lib/ghost4j-1.0.1.jar ...