繁体   English   中英

在一大群罐子里找到一个特定的类

[英]finding a specific class in a large group of jars

在不同文件夹(窗口)中的一大组jar文件中查找类的推荐方法是什么? 目前我使用editplus搜索看起来很棒。 但也许我错过了一个更好的方法?
谢谢。
编辑我需要以编程方式找到它。

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

对于Windows,请替换:with; 在“罐子” - 变量和sed命令。 sed是gnu-tools的一部分 - 它们有一个二进制win32端口,它包含grep,sed,sh.exe和更多有用的工具。

将驱动程序替换为%1,使其成为可参数化的脚本。

我会使用像在线搜索工具

试试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

由于您正在使用IntelliJ,您可以导航到相关的类(转到 - >类...),然后在项目视图中显示它(Alt-F1 - >项目视图)。

如果您已经有罐子 ,我建议使用JD GUI

只需打开罐子(将所有罐子拖放到UI中),然后按CTRL + SHIFT + T. 输入类名,您将获得该类所在的所有罐子的列表。

如果您知道类名 ,而不是jar,请使用搜索maven工具。 http://search.maven.org/

对于商业客户,我通常使用maven。 我设置了一个内部nexus存储库,然后使用它的搜索。

如果项目是在Eclipse中设置的 ,请使用CTRL + SHIFT + T并键入类名

如果项目在IntellJ中 ,请使用CTRL + N并键入类名

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM