Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find the packages defined in a jar?

Tags:

package

maven

jar

I have a bunch of JAR files (from a maven2 project) and maven reports some package could not be found (org.openanzo.client.jena to be exact). I want to dig into the JAR files downloaded as the result of maven dependency resolution and find what packages are thus available from these JAR files. Insights?

UPDATE: Apparently, the only good solution to inspect insides of a jar file is the "jar" utility or one can use the facilities of their IDE to do so.

like image 300
Ashkan Kh. Nazary Avatar asked Jan 20 '11 07:01

Ashkan Kh. Nazary


1 Answers

If you are on Linux or a Mac, you could go to the terminal at the root of the folder containing your JARs and type:

   # grep -ri "org.openanzo.client.jena" *

It will return a recursive list of all JAR files that contain that package name. If it returns 0 results, then none of those JARS contain that package.

If you wanted to do a more exhaustive search, you could unJAR the JAR files. The directory structure and .class files will be organized by packages in folders.

  # jar xvf filename.jar

If you are on Windows, you can unJAR a JAR file using a tool such as 7Zip.

like image 86
jmort253 Avatar answered Sep 19 '22 12:09

jmort253