'Extracting Specific class file from EAR file in Unix

I have an ear file which contains around 20 jar files. Now there is a specific jar file in this EAR say jar 1 which contains application class files.

Now I want a single line command in unix which can extract a particular class file from that jar (jar 1 in this case) present inside EAR.



Solution 1:[1]

I found a way to do it in 2 stages:

  1. Find the file you want:

    jar tvf file.ear | grep file_you_want.abc
    

    You will get the file you want with its path.

  2. Extract it:

    jar xvf file.ear path/to/file/file.abc
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tripleee