开发者

finding a specific class in a large group of jars

What is the recommended way to locate a class in a large group of jar files in different folders (windows)? currently I use editplus search which 开发者_开发技巧seems great . but maybe I am missing a better way?

thanks.

EDIT I need to find it not programatically.


Try cf.jar

Usage:

   java  -jar  cf.jar  SEARCH  [DIRECTORY]  [OPTIONS]...

Searches all JAR files in the current directory and its sub-directories for
entries matching the SEARCH argument. If DIRECTORY is provided, searching will
be done in that location instead of the current directory.

SEARCH:

  A search string containing the class name (entry name). Wild card (*) is
  supported. Package separator can be either of `/', `\' or `.'.

  Examples:

    java.lang.String
    java/util/ArrayList
    java/lang/Str*B*er

  If non ".class" entries also need to be searched, option -a (--all-types)
  should be specified. Please see the OPTIONS section for a more detailed
  explanation.

DIRECTORY:

  If this is not provided, current directory and all its sub-directories will
  be used for performing the search. However, if this argument is provided,
  the same and its sub-directories will be used as the location to fetch JAR
  files from.

  If a recursive scan is not needed, option -s (--shallow) can be specified.

OPTIONS:

  -h          --help
                   Shows this help
  -o [path]   --redirect-output
                   Redirect output to a file path supplied.
  -x [x1,x2]  --archive-extensions
                   Extensions in addition to the default ".jar". Comma or space
                   separated list accepted.
  -i          --insensitive-case
                   Case insensitive search.
  -q          --quiet
                   Silent search without the progress bar animation.
  -a          --all-types
                   Removes the filtering on ".class" types so that other types
                   such as ".properties", ".xml", etc can also be searched for.
  -s          --shallow
                   Performs a shallow search. Doesn't recurse.

Examples:

   java  -jar  cf.jar  org/apache/log4j/Level  D:\Frameworks
   java  -jar  cf.jar  *OracleDriver  C:\oracle -x jar,zip
   java  -jar  cf.jar  messages.properties  D:\IBM\WebSphere -a -x jar,war,ear
   java  -jar  cf.jar  util.*  D:\Java -i -q


jars=/opt/java/jre/lib/ext/mail.jar:/opt/java/jre/lib/ext/postgresql.jar
for jar in $(echo $jars | sed 's/:/ /g'); do 
    jar -tf $jar | grep Driver && echo $jar
done

For Windows, replace : with ; in "jars"-Variable and sed command. sed is part of the gnu-tools - there is a binary win32 port of them, which contains grep, sed, sh.exe and much more useful tools too.

Replace Driver with %1 to make it a parametrizable Script.


I would use online search tools like

  • http://jarsearch.com
  • http://jarvana.com


Since you're using IntelliJ you can navigate to the class in question (Go To -> Class...) and then show it in the project view (Alt-F1 -> Project View).


If you already have the jars, I suggest using JD GUI.

Simply open the jars (drag and drop all of them into the UI), then do CTRL+SHIFT+T. Type in the classname, and you get a listing of all jars that the class is located in.

If you know the class name, but not the jar, use the search maven tools. http://search.maven.org/

For commercial clients, I usually use maven. I setup an inhouse nexus repository, and then use the searches from it.

If the project is setup in Eclipse, use CTRL+SHIFT+T and type the classname

If the project is in IntellJ, use CTRL+N and type the class name

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜