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

Announcements
Streamlining user types in Qlik Cloud capacity-based subscriptions: Read the Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to create Routines and Use them in tJava

Hi
I have a particular business requirement for which I had to write my own java code and Now I want to put this code into routines.
The problem I encounter is strange Even though I tell it to put in a particular package It doesn't put the code into that package and even if I change it manually it keeps giving me errors.
It always put my code into some weekly_dashboard package.
And Pls give me information on how to use these routines in tJava or any component once I get this working.
Thanks
Surya
Labels (3)
16 Replies
Anonymous
Not applicable
Author

Hello
weekly_dashboard is your project name, all the routines created by users are put in the package: routines.projectName.
The problem I encounter is strange Even though I tell it to put in a particular package

You are creating some folders, not package.
Please see the screenshots.
Best regards

shong
Anonymous
Not applicable
Author

Hi Shong
Thanks for the quick reply.
But I am still facing the same problem sending you screen shots of all the steps.
I followed your instructions but still it gives errors in the package.
Thanks
Surya
Anonymous
Not applicable
Author

hi,
i created a dummy routine under a folder called:
forumQuestions
NOTE: the name of the folder does not need to be used.
my routine:
package routines.proj_comcare;
public class ShowMyMessage {
/**
* ShowMyMessage: not return value, only print "hello" + message.
*
*
* {talendTypes} String
*
* {Category} SomeCategoryToChoose
*
* {param} string("world") input: The string need to be printed.
*
* {example} helloExemple("world") # hello world !.
*/
public static void helloExample(String message) {
if (message == null) {
message = "World";
}
System.out.println("Hello " + message + " !");
}
}

NOTE: there is the Category - that is what is used by the tJava components
{Category} SomeCategoryToChoose
EXAMPLE:
create a new job add a tJava and press CTRL + space; i get the screenshot below:

then in tJava i end up with:
ShowMyMessage.helloExample("nicolas message 1");

hope it helps,

Nicolas

www.brainpowered.net
Anonymous
Not applicable
Author

Hi Nicholas
Thanks for the response but the problem I am facing is that when ever I create a routine the routine starts throwing errors as shown in image no matter what I put in package name it keeps giving me the same error.
I am little stuck here 😞
Regards
Surya
Anonymous
Not applicable
Author

HI
Any body from Talend Support Pls help 😞
I am right now stuck at this point.
Regards
Surya
Anonymous
Not applicable
Author

suryavikas,
could you please post the code of your routine or use the code that i have posted?
i am using version 3, what version are you using?
Nicolas
Anonymous
Not applicable
Author

Hi Nicolas
Pls find step by step details how I create routine but it doesnt work for me 😞 and I am also using Talend 3
Code of the routine.
// template routine Java
package routines.weekly_dashboard;
/*
* user specification: the function's comment should contain keys as follows: 1. write about the function's comment.but
* it must be before the "{talendTypes}" key.
*
* 2. {talendTypes} 's value must be talend Type, it is required . its value should be one of: String, char | Character,
* long | Long, int | Integer, boolean | Boolean, byte | Byte, Date, double | Double, float | Float, Object, short |
* Short
*
* 3. {Category} define a category for the Function. it is required. its value is user-defined .
*
* 4. {param} 's format is: {param} <type> <name>
*
* <type> 's value should be one of: string, int, list, double, object, boolean, long, char, date. <name>'s value is the
* Function's parameter name. the {param} is optional. so if you the Function without the parameters. the {param} don't
* added. you can have many parameters for the Function.
*
* 5. {example} gives a example for the Function. it is optional.
*/
public class test123 {
/**
* helloExample: not return value, only print "hello" + message.
*
*
* {talendTypes} String
*
* {Category} User Defined
*
* {param} string("world") input: The string need to be printed.
*
* {example} helloExemple("world") # hello world !.
*/
public static void helloExample(String message) {
if (message == null) {
message = "World";
}
System.out.println("Hello " + message + " !");
}
}
Attached images of the step by step process.
Regards
Surya
Anonymous
Not applicable
Author

Any inputs
Pls help 😞

Surya
Anonymous
Not applicable
Author

what is the error that you're getting at this line?
package routines.weekly_dashboard;

i think you need to change it back to
package routines;