« October 2005 | Main | January 2006 »

December 2005 Archives

December 5, 2005

Can I have Your Library Version, Please?

A simple question difficult to answer?

Not really. Java provides all the means you need to answer the question: The methods in the java.lang.Package class.

Usage

public void dumpPackageInformation(String name) {
  Package p = Package.getPackage(name);
  System.out.println("Package Name: " + p.getName());
  System.out.println("\tImplementation Title: " + p.getImplementationTitle());
  System.out.println("\tImplementation Vendor: " + p.getImplementationVendor());
  System.out.println("\tImplementation Version: " + p.getImplementationVersion());
  System.out.println("\tSpecification Title: " + p.getSpecificationTitle());
  System.out.println("\tSpecification Vendor: " + p.getSpecificationVendor());
  System.out.println("\tSpecification Version: " + p.getSpecificationVersion());
}

dumpPackageInformation("java.lang");

Requirements (A Call to All Library Providers!)
There is one requirement to make this work properly. To obtain this information a library's META-INF/Manifest.mf must contain these lines

Implementation-Title:
Implementation-Vendor:
Implementation-Version:
Specification-Title:
Specification-Vendor:
Specification-Version:

Exercise
Replace System.out.println() by using a common debugging library.

About December 2005

This page contains all entries posted to Olaf Heimburger's Blog in December 2005. They are listed from oldest to newest.

October 2005 is the previous archive.

January 2006 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type and Oracle