命令行快速找出class文件所在的jar包

for %i in (dir/b/s *.jar) do 7z l %i | findstr XDatabase.class


示例输出:
D:\shared\xsql>for %i in (dir/b/s *.jar) do 7z l %i |findstr XDatabase.class

D:\shared\xsql>7z l dir/b/s   | findstr XDatabase.class

D:\shared\xsql>7z l db2jcc.jar   | findstr XDatabase.class

D:\shared\xsql>7z l db2jcc_license_cu.jar   | findstr XDatabase.class

D:\shared\xsql>7z l jconn3.jar   | findstr XDatabase.class

D:\shared\xsql>7z l jodbc.jar   | findstr XDatabase.class

D:\shared\xsql>7z l jTDS3.jar   | findstr XDatabase.class

D:\shared\xsql>7z l mlscript.jar   | findstr XDatabase.class

D:\shared\xsql>7z l msbase.jar   | findstr XDatabase.class

D:\shared\xsql>7z l mssqlserver.jar   | findstr XDatabase.class

D:\shared\xsql>7z l msutil.jar   | findstr XDatabase.class

D:\shared\xsql>7z l mysql-connector-java-5.1.6-bin.jar   | findstr XDatabase.class

D:\shared\xsql>7z l ojdbc14.jar   | findstr XDatabase.class

D:\shared\xsql>7z l postgresql-8.4-701.jdbc4.jar   | findstr XDatabase.class

D:\shared\xsql>7z l sqlite.jar   | findstr XDatabase.class

D:\shared\xsql>7z l sqlitejdbc-v056-zentus.jar   | findstr XDatabase.class

D:\shared\xsql>7z l sqljdbc.jar   | findstr XDatabase.class

D:\shared\xsql>7z l ULjDatabaseTransfer.jar   | findstr XDatabase.class

D:\shared\xsql>7z l UltraLiteJ.jar   | findstr XDatabase.class

D:\shared\xsql>7z l UltraLiteJ12.jar   | findstr XDatabase.class

[b]D:\shared\xsql>7z l xsql.jar   | findstr XDatabase.class
2010-12-24 21:05:40 .....        30863        14443  [/b]com\sean\db\XDatabase.class


上述命令弄得还是比较粗糙,干脆写一个批处理findclass.bat
内容如下:
@echo off
SETLOCAL

set WHICH_CLASS=%1
echo WHICH_CLASS=%WHICH_CLASS%

for /F %%i in ('dir /A:-D /S /B *.jar') do 7z l %%i | findstr %WHICH_CLASS% && echo %WHICH_CLASS% found in: "%%i"
echo "Finished class finding..."
echo "======================================"
ENDLOCAL


这样想查找一个class就很容易了:
引用
findclass com\\sybase\\afx\\util\\StringUtil.class
WHICH_CLASS=com\\sybase\\afx\\util\\StringUtil.class
2012-02-27 13:14:36 .....        15230         5915  com\sybase\afx\util\StringUtil.class
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-client.jar"
2012-02-27 13:14:36 .....        15230         5915  com\sybase\afx\util\StringUtil.class
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-server-rt.jar"
"Finished class finding..."
"======================================"


其实,最想弄的,是把7z的源码稍作修改,直接让7z l <文件> | findstr <class> 直接同时输出文件名,那是最好的办法。

你可能感兴趣的:(oracle,mysql,jar,Sybase,Class)