Instantiating an application's Package class
I'm trying to get a reference to a Package object for my application ( which
is contained in a JAR file) so that I can access version information in its
manifest. Something like this:
Class c = getClass(); // my application
Package p = c.getPackage();
String version = p.getImplementationVersion();
// now display it in an about box as version information, etc.
I get the Class object, but the getPackage() method returns null. If I inspect
the collection of packages returned from the static method Package.getPackages(),
I only find packages that are loaded by my application, not the application's
package itself. This suggests that I would have to explicitly instantiate
my application's Package object -- but that is where I abandon hope and curl
up into a ball of whimpering fetal impotence.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL