[resolved] Undefined function and use tLibraryLoad

One Star

[resolved] Undefined function and use tLibraryLoad

Hello,
I need to use the library "commons-lang3" and more specically the function "unescapeHtml4".
So I use a tLibraryLoad and a tjava. In the tjava I just have "System.out.println(unescapeHtml4("<Français>"));"
But I have the message error : "La méthode unescapeHtml4(String) est indéfinie pour le type test_library"

So I've tried with another method : I use the "User Libraries Preferences". I add the .jar in this window
I use just a tjava with :
String test = "<Français>";
System.out.println(org.apache.commons.lang3.StringEscapeUtils.unescapeHtml3(test));
But I have the message error :
connecting to socket on port 3463
connected
Exception in thread "main" java.lang.Error: java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringEscapeUtils
at sis.test_library_0_1.test_library.tJava_1Process(test_library.java:1313)
at sis.test_library_0_1.test_library.runJobInTOS(test_library.java:1506)
at sis.test_library_0_1.test_library.main(test_library.java:1359)
Caused by: java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringEscapeUtils
at sis.test_library_0_1.test_library.tJava_1Process(test_library.java:1275)
... 2 more
disconnected
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringEscapeUtils
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 3 more


How can I use an external library ?

(I've take the library "commons-lang3-3.1-bin.zip" on this website http://commons.apache.org/lang/download_lang.cgi)
Thank you,
Carole

Accepted Solutions
Community Manager

Re: [resolved] Undefined function and use tLibraryLoad

Hi
You should import the class before using it, go to the advanced setting tab of tJava:
import org.apache.commons.lang3.StringEscapeUtils.unescapeHtml4;

or use the class with full package path:
System.out.println(org.apache.commons.lang3.StringEscapeUtils.unescapeHtml4("<Français>"));
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] Undefined function and use tLibraryLoad

Hi
You should import the class before using it, go to the advanced setting tab of tJava:
import org.apache.commons.lang3.StringEscapeUtils.unescapeHtml4;

or use the class with full package path:
System.out.println(org.apache.commons.lang3.StringEscapeUtils.unescapeHtml4("<Français>"));
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] Undefined function and use tLibraryLoad

Thank you !
It's work well with the second method ! :-)