使用命令行快速找出Class文件所在的Jar文件
由于jar命令去查找class文件速度比较慢,我个人尝试使用7z.exe,7z.dll,结合批处理,效果非常不错。
请看示例:
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
最末一行展示的是最终结果。
将上述逻辑写成批处理:
@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
运行一下命令:
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..." "======================================"
相关推荐
吹云 2020-11-05
84407805 2020-11-01
曾是土木人 2020-10-31
87201442 2020-10-15
java0 2020-09-29
81437716 2020-09-18
81437716 2020-09-13
bluecarrot 2020-09-11
myCat 2020-09-09
83427718 2020-09-07
85560694 2020-09-03
89520991 2020-08-21
89550191 2020-08-09
katie000 2020-08-04
hunningtu 2020-07-30
89961330 2020-07-28
yuzhongdelei0 2020-07-28
yuzhongdelei0 2020-07-27