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.
JarClassSearcher是一款实用工具,帮助开发者自动查找指定类文件所在的JAR包及其位置。通过配置搜索目录及目标类名,该工具可在控制台及文件中输出搜索结果,适用于解决因类文件版本不一致导致的问题。
811

被折叠的 条评论
为什么被折叠?



