IBM Support

Searching through Jar Files to Find a Specific Class

Troubleshooting


Problem

There are times when programming in Java or debugging Java applications that you need to know if JAR files is a directory contain a specific class file. This document describes a method to quickly search through JAR files within a directory to find specific class files on the iSeries.

Resolving The Problem

A simple QShell script can be used to search through jar files to find a specific class. The syntax is as follows:

for x in *.jar; do echo $x; jar -tvf $x | grep -i search_string; done;

To use this command, do the following:

1.Type QShell using the STRQSH command.
2.Change to the directory where the jar files exist using the cd command.
3.Run the script, replacing the search_string parameter with the desired search string.
For example, this sequence searches through jar files in the CommerceServer55/wc.ear directory for any class that contains OrderItemDataBean. Six matching classes are found in 2 jar files.

STRQSH
===> cd /qibm/proddata/commerceserver55/wc.ear
===> for x in *.jar; do echo $x; jar -tvf $x | grep -i OrderItemDataBean; done;
Catalog-ProductManagementLogic.jar                                                                        
Enablement-BaseComponentsLogic.jar                                                                        
Enablement-IntegrationLogic.jar                                                                          
Enablement-RelationshipManagementLogic.jar                                                                
Marketing-CampaignsAndScenarioMarketingLogic.jar                                                          
Marketing-CustomerProfilingAndSegmentationLogic.jar                                                      
Member-MemberManagementLogic.jar                                                                          
Merchandising-PromotionsAndDiscountsLogic.jar                                                            
Order-OrderCaptureLogic.jar                                                                              
 23149 Thu May 29 03:57:38 CDT 2003 com/ibm/commerce/order/beans/OrderItemDataBean.class                  
   883 Thu May 29 02:24:54 CDT 2003 com/ibm/commerce/order/beansrc/OrderItemDataBeanBase.class            
  2799 Thu May 29 02:25:26 CDT 2003 com/ibm/commerce/tools/optools/order/beans/CSROrderItemDataBean.class
Order-OrderManagementLogic.jar      
  2663 Thu May 29 03:50:22 CDT 2003 com/ibm/commerce/inventory/beans/BackOrderItemDataBean.class      
  3064 Thu May 29 03:50:24 CDT 2003 com/ibm/commerce/inventory/beans/PackslipOrderItemDataBean.class  
   619 Thu May 29 03:50:28 CDT 2003 com/ibm/commerce/inventory/beansrc/BackOrderItemDataBeanBase.class
Trading-AuctionsAndRFQsLogic.jar                                                                      
WebSphereCommerceServerExtensionsLogic.jar

[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"}]

Historical Number

348304303

Document Information

Modified date:
18 December 2019

UID

nas8N1015969