Customized Utility 2: JarClassSearcher

      In some occasion we offen need to know a Class belongs to which jar in lots of jars, for example: if we want to know org.jboss.security.SecurityAssociation refered jar under JBOSS_HOME, we all know there are quite a lot number of jars existed in JBOSS_HOME, So it's obviously impossiable to do this work manually. JarClassSearcher can help us to complete this work automatically.

 

Functionality:

      JarClassSearcher utility can help you find a Class belongs to which jars, the jars position you should defined through JarClassSearcher.xml's 'searcher.folder' attribute, the Class name which you want to search you also need to define in JarClassSearcher.xml file.  The search result can be show both Console and File(Opational).

 

Utility Consists:

      JarClassSearcher consists of Three part:

      1. Runnable lib folder(contain all jar files);

      2. Configuration file(JarClassSearcher.xml) ;

      3. Executable script file both Windows and Linux(run.cmd and run.sh).

the figure below has a detailed instrcution.

 JarClassSearcher.xml contains three attributes:

 

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
	<entry key="searcher.folder">C:\\jboss-eap-4.3\\jboss-as</entry>
	<entry key="searcher.class">org.jboss.security.SecurityAssociation</entry>
	<entry key="result.file">true</entry>
</properties>

       searcher.folder: the jars folder

       searcher.class: class name you what to search

       result.file: whether save the search result to file.

 

How to use?

      I will implement this section with the purpose of solving s problem. at the beginning I will give the problem first, in http://kylinsoong.iteye.com/blog/1019829 part two, when EJB  our Client(J2SE environment) Look up Remote Service, throw a error:java.lang.NoSuchMethodError, to solve this problem we should know class 'org.jboss.security.SecurityAssociation' exists which jars first. so JarClassSearcher on his way.

1. Use a file editor tool to editor JarClassSearcher.xml to define the folder all jars exists, the class name we want to search, whether need to save to file, the belows show the jars folder is JBOSS_HOME, the class name is 'org.jboss.security.SecurityAssociation' , we need to save the result to file. 

 2. Start a command line, navigate to JarClassSearcher folder and execute 'run.cmd' if you are in Windows system;

 3. check the result:

 the result also can be found in file

 the result show org.jboss.security.SecurityAssociation has been found 5 times, and position as result showed.

 

Supplement Claims:

      JarClassSearcher.xml searcher.class attribute also support other pattern, if we want to search  org.jboss.security.SecurityAssociation, we can set the searcher.class as following:

org.jboss.security.SecurityAssociation.java
org.jboss.security.SecurityAssociation.class
org/jboss/security/SecurityAssociation
org\jboss\security\SecurityAssociation
SecurityAssociation
SecurityAssociation.java
SecurityAssociation.class

 no matter which formats you have set, the result is the same.

 

Ending

      The attached file 'JarClassSearcher.rar' contain both JarClassSearcher utility and src code.  

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值