Transformations > Java transformation > Classpath configuration
  

Classpath configuration

If you use third-party or custom Java packages in the Java transformation, you must configure the classpath. The Secure Agent includes the classes and resource files within the classpath when it compiles the Java code. You do not need to configure the classpath if you use only built-in Java packages.
For example, you import the Java package converter in the Java transformation and define the package in converter.jar. You must add converter.jar to the classpath before you compile the Java code. However, if you import the package java.io, you do not need to set the classpath because java.io is a built-in Java package.
Set the classpath to each JAR file or class file directory associated with the Java package. Separate multiple classpath entries with a semicolon (;) on Windows or a colon (:) on UNIX. The JAR or class files must be accessible by the Secure Agent.
If you use the Java transformation in an elastic mapping, the files must be stored in the following directory on the Secure Agent machine:
<Secure Agent installation directory>/ext/ctjars
Additionally, consider the following guidelines for elastic mappings:
If you use a serverless runtime environment, the files must be stored in the supplementary file location. If you update the files, you must redeploy the serverless runtime environment for the changes to take effect. For more information about the location, see Administrator in the Administrator help.

Classpath values

If you use third-party or custom Java packages in the Java transformation, configure at least one classpath value.
You can set the following classpath values:
JVMClassPath property for the Secure Agent
The Secure Agent uses this classpath when you design and validate the Java transformation, run the mapping from the Mapping Designer, or run the mapping task. This classpath applies to all mappings and mapping tasks that run on the agent.
Set the JVMClassPath property for the Secure Agent in Administrator.
Set this property or set the CLASSPATH environment variable on the Secure Agent machine. You do not need to set both classpath values.
CLASSPATH environment variable
The Secure Agent uses this classpath when you design and validate the Java transformation, run the mapping from the Mapping Designer, or run the mapping task. This classpath applies to all mappings and mapping tasks that run on the agent.
Set the CLASSPATH environment variable on the Secure Agent machine.
Set the CLASSPATH environment variable or set the JVMClassPath property for the Secure Agent. You do not need to set both classpath values.
Design time classpath
The Secure Agent uses this classpath when you design and validate the Java transformation and when you run the mapping from the Mapping Designer. This classpath is not used when you run the mapping through a mapping task.
Set the design-time classpath when you want to test the transformation and neither the JVMClassPath property nor the CLASSPATH environment variable contain the required packages. If you configured the JVMClassPath property or the CLASSPATH environment variable to include the required packages, then you do not need to configure the design time classpath.
You configure the design-time classpath in the Java transformation advanced properties.
Java Classpath session property
The Secure Agent uses this classpath when you run the mapping task. This classpath applies only to the mapping task in which the property is set.
Set the Java Classpath session property when you want the classpath to apply to one mapping task but not others. If you configured the JVMClassPath property or the CLASSPATH environment variable to include the required packages, then you do not need to configure the Java Classpath session property.
Set the Java Classpath session property in the advanced session properties of the mapping task.
If you set multiple classpath values, the Secure Agent uses all of the classpaths that apply. For example, you set the JVMClassPath property for the Secure Agent, the CLASSPATH environment variable, and the design time classpath in the Java transformation. When you compile the Java code in the Java transformation or run the mapping through the Mapping Designer, the Secure Agent uses all three classpaths. When you run the mapping through a mapping task, the Secure Agent uses the JVMClassPath and the CLASSPATH environment variable only.
Warning: If you set multiple classpaths, ensure that they do not create multiple copies of a class or resource which can cause runtime errors.

Configuring the JVM Classpath for the Secure Agent

Configure the DTM JVMClassPath property for the Secure Agent on the Secure Agent page in Administrator. The Secure Agent uses this classpath when you design and validate the Java transformation, run the mapping from the Mapping Designer, or run the mapping task. You must restart the Secure Agent after you configure this classpath.
    1. In Administrator, select Runtime Environments.
    2. Select the Secure Agent.
    3. On the Secure Agent page, click Edit.
    4. In the system configuration details, select the following values:
    Option
    Value
    Service
    Data Integration Server
    Type
    DTM
    5. In the row for the JVMClassPath property, click Edit.
    6. Append your classpath to the existing classpath value.
    On Windows, use a semicolon (;) to separate classpath entries. On UNIX, use a colon (:).
    Note: Do not delete the default value, 'pmserversdk.jar'.
    7. Click Save.
Restart the Secure Agent after you update the system configuration details.

Configuring the CLASSPATH environment variable

Configure the CLASSPATH environment variable on the Secure Agent machine. The Secure Agent uses this classpath when you design and validate the Java transformation, run the mapping from the Mapping Designer, or run the mapping task. You must restart the Secure Agent after you configure this classpath.
You configure the CLASSPATH environment variable differently on Windows and UNIX.

Configuring the CLASSPATH on Windows

On Windows, you configure the CLASSPATH environment variable from the Advanced System Properties in the Control Panel.
    1. Open the Advanced System Properties from the Windows Control Panel.
    2. Click Environment Variables.
    3. Under System variables, click New.
    4. Set the variable name to CLASSPATH and the variable value to the classpath.
    5. Click OK.
Restart the Secure Agent after you configure the environment variable.

Configuring the CLASSPATH on UNIX

On UNIX, you configure the CLASSPATH environment variable from a UNIX shell.
    bulletEnter one of the following commands:
Restart the Secure Agent after you configure the environment variable.

Configuring the design time classpath

Configure the design time classpath in the Java transformation advanced properties. The Secure Agent uses the design time classpath when you design and validate the Java transformation and when you run the mapping from the Mapping Designer.
    1. Open the mapping that contains the Java transformation.
    2. Select the Java transformation and click the Advanced Properties tab.
    3. Enter the classpath in the Design Time Classpath field.

Configuring the Java Classpath session property

Configure the Java Classpath session property in the advanced session properties of the mapping task. The Secure Agent uses this classpath when you run the mapping task.
    1. Open the mapping task.
    2. On the Schedule page, scroll down to the advanced session properties, and click Add.
    3. Under General Options Settings, select Java Classpath.
    4. Enter the classpath in the Set the Session Property Value field.
    5. Click Save.