Importing JAR files to allow use of external Java classes
Occasionally, during development it is necessary (or simpler) to make use of Java classes that aren't already included within Talend. These may be pre-existing Java code such as financial calculations or open source libraries, which are provided by The Apache Software Foundation (www.apache.org).
In this example, we will make use of a simple Java class ExternalValidations
and its ExternalValidateCustomerName
method. This class performs the following simple validation:
if (customerName.startsWith("J ")) { return customerName.replace("J ", "James "); } else { if (customerName.startsWith("Jo ")) { return customerName.replace("Jo ", "Joanne "); } else { return customerName; } }
Getting ready
Open job jo_cook_ch05_0050_externalClasses
.
How to do it…
Create a code routine called
externalValidation
.Right-click and select the option Edit routine Libraries.
In the next dialogue, click on New.
Select the option Browse a library file...