Skip to Content
Author's profile photo Nabendu Sen

Add External Jar files in your UDF – Working with API’s


Writing UDF was always more easier than writing a Java code outside ESR and bring it back as Imported Archive.

You can find all the details in this blog about implementing Java Mapping directly in your ESR :

Write Java Mapping directly in ESR!

It was always been straight forward to add External Jar files in different Java IDE (Like Eclipse, SAP NWDS etc.) you

used to develop your Java mappings. But other than you are using NWDS as your Service Repository, you always have

to perform couple of extra steps in case of Java mapping compared with UDFs (User Defined Functions).

This blog will be helpful for Swing client.

Also we add these Jar files locally to compile our Java code and it has to be available next time to us for further

enhancements of the code. But with Function Library feature this Jar would be available throughout the SWCV.

Now with availability of different Open source API’s and Java libraries, you would always want to add them in

your code to reduce the development effort or to achieve specific functionality.

Example API

In PI, we commonly use String related functions. org.apache.commons.lang.StringUtils is a very powerful API

available and it provides nice utilities to work with strings like checking for numeric/alphanumeric, finding difference

or reversing other than common string functionality I will take this one as an example.

You can download Jar file from below website:

Now you need to download correct API depending on your PI server JDK version (Not JRE). Commons Lang 2 for

Java 1.2+ and Commons Lang 3 is for Java 6.0+.  I will be using Lang 2.


Now the file ‘’ file is downloaded. Now unzip and you can see like below:


Keep in mind we need to upload “.jar” file in our PI ESR and not the “.zip” file.

Now open ESR, create Imported Archive (‘Apache_StringUtils‘ in the Pic) and

upload ‘commons-lang-2.6.jar’, you can see Class files like below available within the library:


Use of Jar inside Function Library UDF

Create Function Library as described in the blog:

PI 7.1 Concept of Function Library in Process Integration – Process Integration – SCN Wiki

Go to ‘Archives Used’:


Select your Archive created above.


Now in your ‘Import Instructions’ tab, add the Package name just like you use in your Java code.


It is ready to be used under UDF. I am going to use “equals” function to test.

Now all the StringUtils functions are NULL safe.

Sample UDF Code

public String StringManipulation(String firstStr, String secondStr, Container container) throws StreamTransformationException{
      return "YES";
  return "NO";


Access the code inside Message Mapping

You can use your Function Library inside any Message Mapping throughout the SWCV. It would look like below:Pic11.JPG

With the use of Open Source API’s you can find easy solution for different difficult requirements, sometimes few are beyond the capability of basic Java functions.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.