TOMÁŠ HUBÁLEK BLOG: BAVTE SE PŘIMĚŘENĚ…

How to extract list of packages from JAR file

Written By: Tomáš Hubálek - Jul• 15•09

I’m currently working on some project using NetBeans Platform. This project need to have list of public packages from the jar in configuration file. So I write this quite simple code to do it manually

unzip -vb commons-beanutils-1.8.0.jar 
      | grep 00000 | cut -c 59- | grep -v META-INF 
      | tr / . 
      | awk '{print "<publicPackage>" $1 "*" "</publicPackage>"}'

A the result is

<publicPackage>org.*</publicPackage>
<publicPackage>org.apache.*</publicPackage>
<publicPackage>org.apache.commons.*</publicPackage>
<publicPackage>org.apache.commons.beanutils.*</publicPackage>
  ...
<publicPackage>org.apache.commons.collections.*</publicPackage>

I love unix text processing utilities…

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

Your email address will not be published. Required fields are marked *