List contents of multiple jar files

前端 未结 9 826
情歌与酒
情歌与酒 2021-02-02 10:50

I am searching for a .class file inside a bunch of jars.

jar tf abc.jar 

works for one file. I tried

find -name \"*.jar\" | xa         


        
相关标签:
9条回答
  • 2021-02-02 11:49

    If you are using Eclipse, you can create a project and add all jars. You will then be able to find a class in any of the jars.

    0 讨论(0)
  • 2021-02-02 11:54

    If you coming to this question and you need to extract all jar files in a windows environment, navigate to the directory where you have saved all the jar files and save a batch file with the following content:

    for /r %%f in (*) do jar -xvf %%f
    

    By running the batch file, it will extract each jar file in the directory. The only thing here is that it will extract in the same directory where the jar file is.

    0 讨论(0)
  • 2021-02-02 11:55

    You need to pass -n 1 to xargs to force it to run a separate jar command for each filename that it gets from find:

    find -name "*.jar" | xargs -n 1 jar tf
    

    Otherwise xargs's command line looks like jar tf file1.jar file2.jar..., which has a different meaning to what is intended.

    A useful debugging technique is to stick echo before the command to be run by xargs:

    find -name "*.jar" | xargs echo jar tf
    

    This would print out the full jar command instead of executing it, so that you can see what's wrong with it.

    0 讨论(0)
提交回复
热议问题