Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I made a custom .jar executable that parsing some PDF files and catching some text values, depending a regex.
All works fine.
Now, i would like to use it in Talend job but i don't know how to do it.
I tried with tLibraryLoad component but it didn't work.
I tried to :
But didn't work too.
Is ther somebody who knows how i can do that.
Thanks from advance.
Hello,
Could you please let us know if this article helps?
Best regards
Sabrina
Hello xdshi,
Thanks for your reply.
I use Talend 6.3.1. i didn't see anything concerning TAC.
If i try to import iText directly in Talend package explorer, i have an "BUILD FAILURE" message.
I don't understand anything in the page link yau gave me. Sorry.
I'm unable to connect to Maven repository.
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Cannot access central (http://repo.maven.apache.org/maven2) in offline mode and the artifact org.apache.maven.plugins:maven-resources-plugin:jar:2.6 has not been downloaded from it before. -> [Help 1]
Offline / Missing artifact com.itextpdf:itextpdf:jar:5.5.13.2
Hello,
Using a tLibraryLoad component to load the jar at the beginning of job, and then write the custom code on tJava, eg:
tLibraryLoad
|
onsubjobok
|
tJava
What's error are you getting?
Best regards
Sabrina
Hello,
You could delete the configuration/.m2 and re-download the jar files which the one that is the issue in this scenario is your routines jar file.
Best regards
Sabrina
Hello Xdshi,
I used a tLibraryLoad component as show in 1 below and i loaded my executable jar ParserPdf.jar as show in 2, 3, 4.
I connected the tLibraryLoad component to tJava componenent with OnSubjobOk link.
I just called my class as show in 2.
This is the issue message i obtain in 2
I deleted the /.m2 repository but i dont know what to do after.
Thanks from advance.
I tried another way with tSystem component as show below.
But i didn't catch nothing in my consol output.
I continue my quest. 😅
Hello,
To enable this tLibraryLoad component to load an external library, you need first to import the library into the component.
Best regards
Sabrina
Hi,
I found how to do for displaying returned values from my .jar with tSystem component. But now i would like to know how catch this values in a tMap component.
If i use this configuration (console output) :
I can displaying the values returned by jar :
But if i configure the tSystem output to global variable as below :
i don't have anything in output :
Maybe my problem come from my jar code. i puting it here :
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.parser.PdfTextExtractor;
//import java.io.*;
import java.util.regex.*;
import java.io.IOException;
public class ParserPdf{
public static Pattern pattern;
public static Matcher matcher;
public static String cdeadh="";
public static String numcmd="";
public static String result="";
public static String newName="";
public static void main(String[] args) {
for(int i=0; i<args.length; i++) {
newName=reader(args[i]);
System.out.println(newName);
reader(args[i]);
}
}
public static String reader(String file) {
PdfReader reader;
String res="";
try {
reader = new PdfReader(file);
String textPdf = PdfTextExtractor.getTextFromPage(reader, 1);
//System.out.println(textPdf);
reader.close();
res=finderCopab(textPdf, "AD"+"[0-9]{3}"+".*");
res=finderArca(textPdf, "22"+"[0-9]{3}"+"[A-Z]"+".*");
res=finderCesaea(textPdf, "CESAEA"+".*");
res=finderCesaew(textPdf, "CESAEW"+".*");
} catch (IOException e) {
e.printStackTrace();
}
return res;
}
// Finder ADH COPAB
public static String finderCopab(String data, String regEx) throws IOException {
pattern = Pattern.compile(regEx);
matcher = pattern.matcher(data);
while(matcher.find()) {
//cdeadh=matcher.toString();
//System.out.println(cdeadh);
cdeadh=matcher.toString().substring(69, 74);
numcmd=matcher.toString().substring(98, 104);
result=cdeadh+"_"+numcmd;
//System.out.println(result);
}
return result;
}
// Finder ADH ARCA
public static String finderArca(String data, String regEx) throws IOException {
pattern = Pattern.compile(regEx);
matcher = pattern.matcher(data);
while(matcher.find()) {
//cdeadh=matcher.toString();
//System.out.println(cdeadh);
cdeadh=matcher.toString().substring(74, 80);
numcmd=matcher.toString().substring(103, 109);
result=cdeadh+"_"+numcmd;
//System.out.println(result);
}
return result;
}
// Finder cession CESAEA
public static String finderCesaea(String data, String regEx) throws IOException {
pattern = Pattern.compile(regEx);
matcher = pattern.matcher(data);
while(matcher.find()) {
cdeadh=matcher.toString().substring(65, 72);
//System.out.println(cdeadh);
if(!cdeadh.equals("CESAEA/")) {
cdeadh=matcher.toString().substring(65, 71);
numcmd=matcher.toString().substring(94, 100);
result=cdeadh+"_"+numcmd;
//System.out.println(result);
}
}
return result;
}
// Finder cession CESAEW
public static String finderCesaew(String data, String regEx) throws IOException {
pattern = Pattern.compile(regEx);
matcher = pattern.matcher(data);
while(matcher.find()) {
cdeadh=matcher.toString().substring(65, 72);
//System.out.println(cdeadh);
if(!cdeadh.equals("CESAEW/")) {
cdeadh=matcher.toString().substring(65, 71);
numcmd=matcher.toString().substring(94, 100);
result=cdeadh+"_"+numcmd;
//System.out.println(result);
}
}
return result;
}
}