One Star

[resolved] The import cannot be resolved

Hello,
I am learning how to use tJavaFlex component. In advanced settings I try to do import of some classes:

import org.json.*;
and I get error "The import org.json cannot be resolved".

I can see that json-simple-1.1.jar is in my calsspath variables (Windows > Preferences > Java > Build Path > Classpath Variables).

I've also tried to add my own json jar to user libraries (Windows > Preferences > Java > Build Path > User Libraries and received same error. I tried dropping my json jar into workspace/Java/lib, to studio/workspace/talen_local_project/libs and to Runtime_ESBSE/lib - did not help. Of course, every time I dropped json jar into a folder I restarted Talend studio. 
I also tried to install this jar as a module - it did not go well either.

I am using Talend Open Studio 6.0 for ESB.

Please help to make java import work!
Thank you!
Svetlana

1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] The import cannot be resolved

Using a tLibraryLoad component to load external jar file before you use it.
tLibraryLoad
   |
onsubjobok
   |
tJavaFlex
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
4 REPLIES
Community Manager

Re: [resolved] The import cannot be resolved

Using a tLibraryLoad component to load external jar file before you use it.
tLibraryLoad
   |
onsubjobok
   |
tJavaFlex
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] The import cannot be resolved

Thank you Shong! Does it mean that I have to do it for every job if I want all of them to have access to the same external library? Is it possible to setup my environment so that all my jobs have access to this library by default without having to introduce this extra component tLibraryLoad?
Thank you,
Svetlana
Community Manager

Re: [resolved] The import cannot be resolved

Yes,  you have to load the jar with tLibararyLoad component in each independent job. Alternatively, if you need to use these same code many time in different job, I would suggest you to create a routine and import external library one time in repository metadata, and call the routine in the job. Please refer to this article to learn how to create a routine and call it in a job.
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] The import cannot be resolved

Thank you very much Shong!