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

Get Talend Open Studio Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.