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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

creation component - import java libraries

Hi,
I create a new java component, which use java libraries. So i add at beginning of my script
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.designer.codegen.config.CodeGeneratorArgument
org.talend.core.model.process.ElementParameterParser
java.awt.Image
javax.imageio.ImageIO
"
%>
But then i trie to use this component in mjob , the generator doesn't add lines in script. Why ?
Labels (3)
18 Replies
Anonymous
Not applicable
Author

Ok, I understand.
Thanks for the quick reply.
Bas.
Anonymous
Not applicable
Author

Is the jar-files must be in the component directory only?
Can I put its in <Talend_home>/lib/java and use its the same way?
Anonymous
Not applicable
Author

Is the jar-files must be in the component directory only?
Can I put its in <Talend_home>/lib/java and use its the same way?

For private usage yes. But if commit to ecosystem, had better include related lib in component folder, unless they have already been used in other component. Notice that if you look into the fresh TOS zip package, the lib folder is not exist at the very beginning, all the lib in %TALEND_HOME%/lib/ are gethered after the studio start.
Anonymous
Not applicable
Author

Now I used my jar's for code executed at runtime of my job.All worked correctly.
But the imports in the scriptlet part (<% %>) to use when generating the component templates, don't work.
Can we make some import declaration in component javajet?
For example, like this:
<%@ jet
imports="
org.talend.core.model.process.INode
org.talend.core.model.metadata.IMetadataTable
org.talend.core.model.metadata.IMetadataColumn
...
org.myproject.myclasses.MyClass
"
%>
I need to use later:
<% MyClass myclass = new MyClass(); %>
How can I do something like this?
Now there is an exception (similar #6 of this list)
BR,
Roman
Anonymous
Not applicable
Author

I want to use classes of my plug-in project when generating the component templates. If I import my class in javajet file, i am getting compilation issue due to the package invisibilty.
In many javajet files I found packages imported only from org.talend.core and org.talend.designer.codegen projects. Is there any limitation to use only these projects as dependencies for generating the component templates?
Regards,
Vijay
Anonymous
Not applicable
Author

Hi,
I reply to this old post because I have the same problems. I am developing a new Talend component which uses XMLRPC to connect to a server. I need many imports, some from XMLRPC libraries. I have made like it's written:
<CODEGENERATION>
<IMPORTS>
<IMPORT NAME="openerp" MODULE="openerp.jar" REQUIRED="true"/>
</IMPORTS>
</CODEGENERATION>
openerp.org.apache.xmlrpc.client.XmlRpcClient client = new openerp.org.apache.xmlrpc.client.XmlRpcClient();
At the runtime, an error appears like "openerp is not recognized as a valid type". What must i do ? This is wrong ?
Thank for help, kind regards.
Zak
Anonymous
Not applicable
Author

Hi
openerp.org.apache.xmlrpc.client.XmlRpcClient client = new openerp.org.apache.xmlrpc.client.XmlRpcClient();

Are you sure that this is the correct package name? I see references on the web to org.apache.xmlrpc.client.XmlRpcClient, but I see none to openerp.org.apache.xmlrpc.client.XmlRpcClient.
You only need to declare the library - it's not necessary to prefix its name to the classes it provides. Try
org.apache.xmlrpc.client.XmlRpcClient client = new org.apache.xmlrpc.client.XmlRpcClient();

Imad
Anonymous
Not applicable
Author

Hi Imad,
Thank you for your quick answer but, I'm sure 0683p000009M9p6.png Because of integrity problems of the officiel XmlRpc library, I have made mine.
I have tried with your version but now I have a "java.lang.NoClassDefFoundError".
Anonymous
Not applicable
Author

Hello, I often had an issue with jars in custom components.
Check if the jar is copied into the lib/java directory under your install path.
It should, but it happened to me that the file was not automatically copied from the component folder to there when installing the component.
Particularly if a previous version of the file (with the same name) was already there, it was not copied.
If this is the case, the workaround is to copy manually the jar.
good luck