Useful bash operations on JAR files

Submitted by Jochus on Wed, 16/06/2010 - 14:06 | Posted in: Linux

Today, a colleague of me teached me some useful commands to execute operations on JAR files

Searching for a class file in a bunch of JAR files

I needed this, as I was looking for a class in the lib folder of JBoss. The lib folder contains a lot of JAR files, so it was rather impossible to search them individually:

<a href="mailto:jochen@baileys">jochen@baileys</a> lib $ grep -ri TreeCacheProvider .
Binary file ./jboss-hibernate.jar matches
Binary file ./hibernate3.jar matches
Binary file ./hibernate-jbosscache-3.3.2.GA.jar matches

Searching for the full package name of a class in a JAR file

Ok, so with the command above, I know TreeCacheProvider is in 3 JAR files, but I want to know the full qualified package name?

<a href="mailto:jochen@baileys">jochen@baileys</a> lib $ jar tvf jboss-hibernate.jar | grep TreeCacheProvider
  3232 Fri Jul 18 14:20:44 CEST 2008 org/jboss/hibernate/cache/DeployedTreeCacheProvider.class

Add new comment

The content of this field is kept private and will not be shown publicly.

Full HTML

  • Lines and paragraphs break automatically.
  • You can caption images (data-caption="Text"), but also videos, blockquotes, and so on.
  • Web page addresses and email addresses turn into links automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <bash>, <cpp>, <css>, <html5>, <java>, <javascript>, <php>, <sql>, <xml>. The supported tag styles are: <foo>, [foo].
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.