« New JDev 10.1.3 EA extension: PMD | Main | Oracle XE: Fixing the StopDB script on Windows »

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.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About This Entry

This page contains a single entry from the blog posted on December 5, 2005 10:46 AM.

The previous post in this blog was New JDev 10.1.3 EA extension: PMD.

The next post in this blog is Oracle XE: Fixing the StopDB script on Windows.

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

Top Tags

Powered by
Movable Type and Oracle