Question
igate global solutions
IN
Last activity: 11 Aug 2015 5:32 EDT
Adding a third party jar
Hello,
I just want to make use of Apache Poi jars in my application for reading data from an excel sheet. So the jars has placed in the server and am not sure whether classpath is set for our jars.
I am getting "org.apache.poi.hssf cannot be resolved to a type" compile time error. I think this error I am getting because of the classpath issue.
So, How to check whether the classpath set for our jars or not. Where can I see the classpath.
-
Like (0)
-
Share this page Facebook Twitter LinkedIn Email Copying... Copied!
Accepted Solution
Pegasystems
IN
Please try this
try{
java.io.InputStream myxls = new java.io.FileInputStream("D:/data/310734488/NAVEEN/Test.xls");
com.pega.apache.poi.hssf.usermodel.HSSFWorkbook wb = new com.pega.apache.poi.hssf.usermodel.HSSFWorkbook(myxls);
com.pega.apache.poi.hssf.usermodel.HSSFSheet sheet = wb.getSheetAt(0);
String a;
for (int j=0; j< sheet.getLastRowNum() + 1; j++) {
com.pega.apache.poi.hssf.usermodel.HSSFRow row = sheet.getRow(j);
com.pega.apache.poi.hssf.usermodel.HSSFCell cell1 = row.getCell(0);
a=cell1.getStringCellValue();
if(!a.equals("")){
ClipboardProperty item= tools.findPageWithException("DeleteItems").getProperty(".pxResults(<APPEND>).BBTRID");
item.setValue(a);
}
}
}
catch(Exception e)
{
oLog.infoForced("caught exception...."+e);
}
Pegasystems
IN
Did you set this in the compile path? Please refer - https://community.pega.com/sites/default/files/help_v718/procomhelpmain.htm
Pegasystems
IN
Also, Apache POI already exists in the Pega platform from version 6 onwards. The packages are renamed from org.apache.poi to com.pega.apache.poi.
igate global solutions
IN
Hi Rajiv,
I am using 6.2 SP2 version and I have below values in DSS.
compiler/defaultClasses = com.ibm.mq.pcf.PCFAgent;com.ibm.mq.MQC
compiler/defaultPaths is blank.
I want to make use of many classes from the jar like org.apache.poi.hssf.usermodel.HSSFWorkbook. Below is my code in a java step of an activity.
try{
java.io.InputStream myxls = new java.io.FileInputStream("D:/data/310734488/NAVEEN/Test.xls");
org.apache.poi.hssf.usermodel.HSSFWorkbook wb = new org.apache.poi.hssf.usermodel.HSSFWorkbook(myxls);
org.apache.poi.hssf.usermodel.HSSFSheet sheet = wb.getSheetAt(0);
String a;
for (int j=0; j< sheet.getLastRowNum() + 1; j++) {
org.apache.poi.hssf.usermodel.HSSFRow row = sheet.getRow(j);
org.apache.poi.hssf.usermodel.HSSFCell cell1 = row.getCell(0);
a=cell1.getStringCellValue();
if(!a.equals("")){
ClipboardProperty item= tools.findPageWithException("DeleteItems").getProperty(".pxResults(<APPEND>).BBTRID");
item.setValue(a);
}
}
}
catch(Exception e)
{
oLog.infoForced("caught exception...."+e);
}
Error:
Test compilation failed: ----------
1. ERROR in Rule_Obj_Activity_RBC_Bank_BFS_Work_TestNav_Action_20150805T065456_027_GMT.java (at line 234)
pega.apache.poi.hssf.usermodel.HSSFWorkbook wb = new pega.apache.poi.hssf.usermodel.HSSFWorkbook(myxls);
^^^^
pega cannot be resolved to a type
Hi Rajiv,
I am using 6.2 SP2 version and I have below values in DSS.
compiler/defaultClasses = com.ibm.mq.pcf.PCFAgent;com.ibm.mq.MQC
compiler/defaultPaths is blank.
I want to make use of many classes from the jar like org.apache.poi.hssf.usermodel.HSSFWorkbook. Below is my code in a java step of an activity.
try{
java.io.InputStream myxls = new java.io.FileInputStream("D:/data/310734488/NAVEEN/Test.xls");
org.apache.poi.hssf.usermodel.HSSFWorkbook wb = new org.apache.poi.hssf.usermodel.HSSFWorkbook(myxls);
org.apache.poi.hssf.usermodel.HSSFSheet sheet = wb.getSheetAt(0);
String a;
for (int j=0; j< sheet.getLastRowNum() + 1; j++) {
org.apache.poi.hssf.usermodel.HSSFRow row = sheet.getRow(j);
org.apache.poi.hssf.usermodel.HSSFCell cell1 = row.getCell(0);
a=cell1.getStringCellValue();
if(!a.equals("")){
ClipboardProperty item= tools.findPageWithException("DeleteItems").getProperty(".pxResults(<APPEND>).BBTRID");
item.setValue(a);
}
}
}
catch(Exception e)
{
oLog.infoForced("caught exception...."+e);
}
Error:
Test compilation failed: ----------
1. ERROR in Rule_Obj_Activity_RBC_Bank_BFS_Work_TestNav_Action_20150805T065456_027_GMT.java (at line 234)
pega.apache.poi.hssf.usermodel.HSSFWorkbook wb = new pega.apache.poi.hssf.usermodel.HSSFWorkbook(myxls);
^^^^
pega cannot be resolved to a type
As you mentioned, that from version 6 Apache POI is already existing in PEGA so May i know how to make use of it and let me know the steps required to follow for having it.
Thanks,
Naveen
Accepted Solution
Pegasystems
IN
Please try this
try{
java.io.InputStream myxls = new java.io.FileInputStream("D:/data/310734488/NAVEEN/Test.xls");
com.pega.apache.poi.hssf.usermodel.HSSFWorkbook wb = new com.pega.apache.poi.hssf.usermodel.HSSFWorkbook(myxls);
com.pega.apache.poi.hssf.usermodel.HSSFSheet sheet = wb.getSheetAt(0);
String a;
for (int j=0; j< sheet.getLastRowNum() + 1; j++) {
com.pega.apache.poi.hssf.usermodel.HSSFRow row = sheet.getRow(j);
com.pega.apache.poi.hssf.usermodel.HSSFCell cell1 = row.getCell(0);
a=cell1.getStringCellValue();
if(!a.equals("")){
ClipboardProperty item= tools.findPageWithException("DeleteItems").getProperty(".pxResults(<APPEND>).BBTRID");
item.setValue(a);
}
}
}
catch(Exception e)
{
oLog.infoForced("caught exception...."+e);
}
igate global solutions
IN
I replaced org with com.pega and now there are no compilation errors. Thank you so much
Updated: 11 Aug 2015 5:32 EDT
Pegasystems
IN
Alternatively, you can add your jar file to compiler/defaultPaths
Please refer - https://pdn.pega.com/forums/prpc/general-questions/external-jar-files-to-pega
or https://pdn.pega.com/forums/prpc/java-activities/3rd-pary-jar-references