2011-04-13 70 views
1

在不同文件夹(窗口)中的大量jar文件组中找到一个类的建议方法是什么? 目前我使用editplus搜索,这似乎很棒。但也许我错过了一个更好的方法?
谢谢。
编辑 我需要找到它不是编程式。在一大群罐子里找到一个特定的类

+1

是你试图以编程的方式做到这一点,或者只是在你选择的文件浏览器/编辑器中? – 2011-04-13 16:02:11

+3

如果你使用Eclipse,你可以在eclipse中做Ctrl + T – 2011-04-13 16:02:19

+0

'CTRL + SHIFT + T'。 – Bozho 2011-04-13 16:13:18

回答

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 
+0

不错。我会尝试 。 – Jeb 2011-04-14 07:49:24

1
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工具的一部分 - 它们有一个二进制win32端口,它包含grep,sed,sh.exe和更多有用的工具。

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

1

我会使用在线搜索工具,如

+0

谢谢。虽然我的意思是在m本地硬盘上搜索,但它仍然有用 – Jeb 2011-04-14 07:50:45

+0

@ user450602我知道这对你的具体问题并不是一个好答案,但作为其他人的参考,这是一个有效的答案 – 2011-04-14 10:16:51

1

由于您使用的IntelliJ您可以导航到该班问题(Go To - > Class ...)和t母鸡在项目视图中显示(Alt-F1 - >项目视图)。

+0

不知道。谢谢。 – Jeb 2011-04-14 07:49:42

0

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

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

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

对于商业客户,我通常使用maven。我建立了一个inora nexus存储库,然后使用它的搜索。

如果该项目是建立在Eclipse,使用Ctrl + Shift + T,然后键入类名

如果该项目是在IntellJ,用CTRL + N和输入类名

相关问题