O'Reilly logo

Talend Open Studio Cookbook by Rick Barton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing one-off pieces of logic using tJava

The tJava component allows one-off logic to be added to a job. Common uses of tJava include setting global or context variables prior to the main data processing stages and printing logging messages.

Getting ready

Open the job jo_cook_ch05_0000_tJava.

How to do it…

  1. Open the tJava component.
  2. Type in the following code:
    System.out.println("Executing job "+jobName+" at "+TalendDate.getDate("CCYY-MM-dd HH:mm:ss"));
  3. Run the job. You will see that message is printed showing the job name and the date and time of execution.

How it works…

If you examine the code, you will see that the Java code is simply added to the generated code as is. This is why you must remember to add ; to the end of the line to avoid compilation ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required