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.