Skip to Content
Author's profile photo Former Member

How to Find Java Library During PI Development

Have you ever encounter a situation where you need a specific class when developing a User-Defined Function, User-Module, or Java Mapping, and don’t know which jar file contains this class.  I get calls from many PI developers with this situation asking me what is the jar filename containing the needed class.  In almost all situations, I was able to respond immediately.  In this blog, I will reveal how this can be done quickly.

I have a text file containing the following information:  jar file name, class path and class name.  By searching for the class name, I can find all the class paths and jar file names where this class name exists.  In order to create this file, I have to do the following in a Windows environment:

1.     Retrieve all the jar files in PI.  This can be done by doing a search for “*.jar” in the directory “…\j2ee\cluster” (including subdirectory), and copy all of them to a temporary location.  During the process, let it override duplicate file names.  (This can be time-consuming process, but it only needs to be done once, and it is worth it.)

2.     Execute the following BAT file, in the same directory as the jar files, to produce the desired text file:

BAT file content:

@Echo OFF

set JAVAPATH=C:\jdk1.6.0_27\bin

set JARFILES=_myJarFiles.txt

set JARLIST=_myJarList.txt

set CLASSLIST=_classList.txt

set PATH=c:\jdk1.6.0_18\bin

dir /b *.jar > %JARFILES%


For /F “tokens=1” %%A IN (%JARFILES%) DO (

   echo ***%%A >> %JARLIST%

   %JAVAPATH%\jar tf %%A >> %JARLIST%


%JAVAPATH%\java -classpath C:\jars\ListJavaClasses.jar com.util.GetJavaClasses %JARLIST% %CLASSLIST%



Please note:

      • JAVAPATH contains the java J2SE installation
      • Modify the locatoin of the ListJavaClasses.jar file as appropriate
      • ListJavaClasses.jar contains the GetJavaClasses program to parse the data  (the program is listed below):
package com.util;


public class GetJavaClasses {
     public void processJarList(InputStream is, OutputStream os) {
          String blanks = "                                                       ";
          try {
               String line = null;
               String jarName = null;
               BufferedReader in = new BufferedReader(new InputStreamReader(is));
               try {
                    while ((line = in.readLine()) != null) {
                         if (line.length() < 10) continue;
                         if (line.substring(0,3).equals("***")) {
                              jarName = line.substring(3) + blanks;
                              jarName = jarName.substring(0, 60);
                         else {
                              int l = line.length();
                              if (line.indexOf(".class", l-7) >= 0) {
                                   String className = jarName + line + "\n";     
                                   writeOutStream(os, className);
               catch (Exception e) {
          catch (Exception e) {
               System.out.println("Error: " + e.getMessage());

     private void writeOutStream(OutputStream out, String val) {
          byte[] b = val.getBytes();
          try {
          catch (Exception e) {
      * @param args
     public static void main(String[] args)  throws Exception{
          String inFile = args[0];               // "/jars/710/_myJarList.txt";
          String outFile = args[1];
          InputStream in = new BufferedInputStream(
               new FileInputStream(inFile));
          FileOutputStream out = new FileOutputStream(outFile);          //"/jars/710/_myClassList.txt");
          GetJavaClasses test = new GetJavaClasses();
          test.processJarList(in, out);


3.     Sample content of the text file (_classList.txt):

                          com/sap/aii/mappingtool/flib3/Arithm.class                         com/sap/aii/mappingtool/flib3/Bool.class                         com/sap/aii/mappingtool/flib3/CalendContainer.class                         com/sap/aii/mappingtool/flib3/CollapseContexts.class                         com/sap/aii/mappingtool/flib3/Constant.class                         com/sap/aii/mappingtool/flib3/Counter.class                         com/sap/aii/mappingtool/flib3/CurDate.class                         com/sap/aii/mappingtool/flib3/DateFunctions.class                         com/sap/aii/mappingtool/flib3/DateTransformer.class                         com/sap/aii/mappingtool/flib3/Dummer.class                         com/sap/aii/mappingtool/flib3/Exists.class                         com/sap/aii/mappingtool/flib3/If.class                         com/sap/aii/mappingtool/flib3/IfS.class                         com/sap/aii/mappingtool/flib3/IfSWithoutElse.class                         com/sap/aii/mappingtool/flib3/IfWithoutElse.class                         com/sap/aii/mappingtool/flib3/MessageHeader.class                         com/sap/aii/mappingtool/flib3/NodeConst.class

Assigned Tags

      1 Comment
      You must be Logged on to comment or reply to a post.
      Author's profile photo Vipin Kanchan
      Vipin Kanchan

      Hi Bill,

      Tried with the above method, but must have got something wrong as i get only the '_myJarFiles.txt' as an output.

      I was trying to find which standard SAP jars would contain the classes for the json conversion in PI 7.4 SPS 10. We need to write an adapter module for ensuring that some json objects are always sent across as json arrays.

      We have the code written but we need to import the json simple jar into the PI server to get it working. We were looking for using standard SAP jars if possible to fulfill this requirement. our code uses the JSONObject, JSONArray, JSONParser and ParseException methods.

      Would be helpful to know which SAP standard jars can be used for getting access to the above methods.