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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Import Jar in Component

Hello,

 

I am writing a component for TOS 6.4.1 in which I want to use ARX Anonymasiation (http://arx.deidentifier.org/). I downloaded the jar from the homepage and importet it to my component (see the XML) and added it to the Java Build Path in TOS.

 <IMPORTS> 
      <IMPORT MODULE="libarx-3.6.0.jar" NAME="libarx" REQUIRED="true"/> 
    </IMPORTS> 

Now I want to use one of the classes.

In the _begin.javajet file I write

imports="
		org.talend.core.model.process.INode 
		org.talend.core.model.process.ElementParameterParser 
		org.talend.core.model.metadata.IMetadataTable 
		org.talend.core.model.metadata.IMetadataColumn 
		org.talend.core.model.process.IConnection
		org.talend.core.model.process.IConnectionCategory
		org.talend.designer.codegen.config.CodeGeneratorArgument
		org.talend.core.model.metadata.types.JavaTypesManager
		org.talend.core.model.metadata.types.JavaType
		java.util.List 
		java.util.Map
		org.deidentifier.arx.ARXAnonymizer
	" 
%>
<% 
CodeGeneratorArgument codeGenArgument = (CodeGeneratorArgument) argument;
INode node = (INode)codeGenArgument.getArgument();
String cid = node.getUniqueName();

 	
org.deidentifier.arx.ARXAnonymizer anonymizer = new org.deidentifier.arx.ARXAnonymizer.ARXAnonymizer();
%>

but I keep getting an error message "The import org.deidentifier cannot be resolved".

 

Thanks for your help.

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Any code inside <% %> is processed by javajet template engine. Javajet engine is like preprocessor that outputs, java code which is later again complied by studio before execution.
So in our case whats happening ?
*Although jar is loaded correctly, it cant be imported and used for javajet engine codes.

Try putting your line of code, which gave the error ,at the end of javajet file outside <%%>.

Have a look at simple javajet file that uses a third party json lib.
https://github.com/Chirgal/tComponents/blob/master/src/main/java/tXmlToJson/tXmlToJson_begin.javajet

View solution in original post

21 Replies
Anonymous
Not applicable
Author

Hello,

Have you put your jar file in your custom component folder? Can you see it from modules view?

Best regards

Sabrina

Anonymous
Not applicable
Author

Hello,

Have you put your jar file in your custom component folder? Can you see it from modules view?

Best regards

Sabrina

Anonymous
Not applicable
Author

Hello,

Have you put your jar file in your custom component folder? Can you see it from modules view?

Best regards

Sabrina

Anonymous
Not applicable
Author

Hallo,

Yes the Jar is in the component folder. When I open the component Designer I can see it.

When I loaded the component for the first time it told me I need to install a required jar and I installed it with the component view of my Job.

Thank you for your reply.
Anonymous
Not applicable
Author

Hi,


@miriull wrote:
Hallo,

Yes the Jar is in the component folder. When I open the component Designer I can see it.

When I loaded the component for the first time it told me I need to install a required jar and I installed it with the component view of my Job.

Thank you for your reply.

You are still getting an error message "The import org.deidentifier cannot be resolved"?

Best regards

Sabrina

Anonymous
Not applicable
Author

Hey,

 

sadly I do. 

Do you have any idea why I get this error message?

 

Thanks,

Miri

Anonymous
Not applicable
Author

Hello,

 

in the meantime I added the URLPath to the XML.:

 <IMPORTS> 
      <IMPORT MODULE="libarx-3.6.0.jar" NAME="libarx" REQUIRED="true" UrlPath="D:\Program Files\TOS_DI-20170623_1246-V6.4.1\plugins\org.talend.libraries.custom_6.4.1.20170623_1246\lib\libarx-3.6.0.jar"/> 
    </IMPORTS> 

But that does not help, either 0683p000009MPcz.png

 

Greetings,

Miri

Anonymous
Not applicable
Author

@ miriull referring to your _begin.javajet file, Shouldnt the line of code be
org.deidentifier.arx.ARXAnonymizer anonymizer = new org.deidentifier.arx.ARXAnonymizer();

Instead of

org.deidentifier.arx.ARXAnonymizer anonymizer = new org.deidentifier.arx.ARXAnonymizer.ARXAnonymizer();
??
Anonymous
Not applicable
Author

Hey,

You are rigth, there is a mistake. Anyway it doesn't even find org.deidentifier so that doesn't seem to be the problem.

Greetings,
Miri