Home > Ubuntu > How to find Java classes in the distribution

How to find Java classes in the distribution

Anyone working on packaging Java software could tell you it’s sometimes difficult to determine in which package a given class might be available. It’s because classes are packaged in .jar files, which are in turn packaged in packages. Being able to tell which .jar files are provided in which packages is not enough, since sometimes the .jar name doesn’t convey any useful information on its contents.

To address that problem, I generated java-Contents files that map out which classes are in which jar, for every package that contain .jar files. For bonus points, I added in which repository (main, universe, multiverse) the package was published.

So the java-Contents file contains one line for each class in each .jar file, with the following format:

packagename repository jarfile javaclass
 

You can download java-Contents files at http://people.ubuntu.com/~ttx/java-Contents. Here is a direct link to the Jaunty one.

If for example, you get a failed compilation complaining about being unable to import a org.xmlpull.mxp1.MXParserFactory class, you can tell which package you should Build-Depend on using the following query:

$ zgrep org.xmlpull.mxp1.MXParserFactory jaunty-java-Contents.gz
jspwiki universe /usr/share/jspwiki/WEB-INF/lib/sandler.jar org.xmlpull.mxp1.MXParserFactory
libxpp3-java main /usr/share/java/xpp3-1.1.3.4.O.jar org.xmlpull.mxp1.MXParserFactory
 

This query, for example, will tell you which packages provide javax.activation.* classes:

$ zgrep javax.activation jaunty-java-Contents.gz | \
  awk '{ print $1 " (" $2 ")" }' | uniq
ec2-api-tools (multiverse)
gcc-snapshot (universe)
glassfish-activation (universe)
glassfish-javaee (universe)
glassfishv2 (multiverse)
jspwiki (universe)
libgeronimo-activation-1.1-spec-java (universe)
libgnujaf-java (main)
openjdk-6-jre-headless (main)
roxen4 (universe)
sun-java6-bin (multiverse)
 

Those two examples just show how much redundancy we currently have in our Java packages. But now, we have one more tool to solve such problems. For those interested, the script used to generate those maps is maintained in a bzr branch here.

Categories: Ubuntu
  1. December 23, 2009 at 12:31

    Cool! This is quite useful; it beats installing all packages myself… I need to repackage libcdk-java, and this will surely come in handy…

    Any chance of seeing the .deb/lib version in the lines as well?

    • Thierry Carrez
      December 23, 2009 at 15:19

      Sounds like a good idea !

  1. December 22, 2009 at 20:07

Leave a comment