读书人

Customized Utility 二: JarClassSear

发布时间: 2012-12-26 14:39:29 作者: rapoo

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.
Customized Utility 二: JarClassSearcher
?JarClassSearcher.xml contains three attributes:

?

?????? 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.?
Customized Utility 二: JarClassSearcher
?2. Start a command line, navigate to JarClassSearcher folder?and execute 'run.cmd' if you are in Windows system;
Customized Utility 二: JarClassSearcher
?3. check the result:
Customized Utility 二: JarClassSearcher
?the result also can be found in file
Customized Utility 二: JarClassSearcher
?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.javaorg.jboss.security.SecurityAssociation.classorg/jboss/security/SecurityAssociationorg\jboss\security\SecurityAssociationSecurityAssociationSecurityAssociation.javaSecurityAssociation.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.??

?

读书人网 >编程

热点推荐