Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
anyxs
Contributor II
Contributor II

Load a custom jar

Hello,We are facing an issue while trying to integrate custom Java classes into a Talend job.Context:We have two custom Java classes:
  • ConvertPdfToImages
  • SupprimerZonesNoiresAvecOcr
The first class uses Apache PDFBox to convert a PDF file into PNG images.We also have the following dependency: pdfbox-app-3.0.7.jar
We created a custom jar containing our Java classes, for example:  ocr-pdf-utils.jar
This jar contains the following classes: ConvertPdfToImages.class   SupprimerZonesNoiresAvecOcr.class     Rect.class
In the Talend job, we want to call the classes from a tJava component, for example:
ConvertPdfToImages.main(new String[] { context.chemin_pdf, context.dossier_images }); SupprimerZonesNoiresAvecOcr.main(new String[] {});
Issue:When we add the custom jar using tLibraryLoad, Talend does not recognize the class in the tJava component and shows a compilation error such as:
ConvertPdfToImages cannot be resolved
We also tried to add the Java classes directly as a Talend Routine, but then we have issues with the Apache PDFBox imports, such as:
import org.apache.pdfbox.Loader; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.rendering.ImageType; import org.apache.pdfbox.rendering.PDFRenderer;

Even when using tLibraryLoad to load pdfbox-app-3.0.7.jar, it does not seem to be enough for the Routine or the tJava component to compile correctly.Questions:1. What is the correct way to add a custom jar containing Java classes to a Talend job so that it is recognized at compile time in a tJava component?2. Where should we add pdfbox-app-3.0.7.jar so that the PDFBox imports are recognized inside a Talend Routine?3. Is it better to:keep the classes in an external jar,convert them into Talend Routines,or use another approach such as tJavaFlex, routine dependencies, Modules, or the job build path?4. Is there any specific Talend Studio configuration required so that both the custom jar and its dependencies are correctly included when generating the job?Additional information:
  • The Java classes compile correctly outside Talend using javac.
  • The PDFBox jar used is pdfbox-app-3.0.7.jar.
  • The custom jar does contain the expected .class files.
  • The main issue seems to be class and dependency visibility at job compile time, not necessarily at runtime.
Any suggestions or feedback from similar experiences would be greatly appreciated.Thank you.
Labels (3)
0 Replies