Home > java > Java Package Versioning

Java Package Versioning

November 8th, 2007 Leave a comment Go to comments

Once again, I stumble onto some feature of the Java platform that I had no idea existed. Today, while researching various ways to store version and build information in jar files, I found this article on Java Product Versioning.

The main idea is that there are now interfaces for accessing special tags in your manifest file. Obviously, the ability to read manifests has been around for a while, but all of the methods I’ve seen were a little hacky. They all involved figuring out the path to your jar, often by parsing the class path and then extracting the manifest from it. This is necessary because, depending on class path order, just asking for ‘/manifest.mf’ with the resource interfaces won’t necessarily get you your manifest.

This article describes the Package class which knows which manifests go with which classes. It also provides methods for accessing the following manifest properties:

Specification-Title: “Java Utility Classes”
Specification-Version: “1.2”
Specification-Vendor: “Sun Microsystems Inc.”
Package-Title: “java.util”
Package-Version: “build57”
Package-Vendor: “Sun Microsystems. Inc.”


Clearly, this has been around for a while. Why does it always take so long for me to find out about these things? Is this not as useful as it seems?

Categories: java Tags:
  1. No comments yet.
  1. No trackbacks yet.