Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to access the Manifest from inside the jar file?

807588May 14 2009 — edited May 15 2009
There's a java.util.jar.JarFile class, which seems to give access to its Manifest, which allows to access its Attributes.
This seems very nice, e.g to store application-wide information (like version info).
I managed to write and build an application, put it into a jar and run it from there.

Now my questions:

How can my code access its own jar file?

Is URL myURL = ClassLoader.getResource("META-INF/MANIFEST.MF") the way to go or is there a more elegant way ?

What's the special purpose/benefit of MANIFEST.MF over any text file as a Resource anywhere in the jar (or on the classpath) ?

Anything to consider regarding debugging support (Eclipse is my favorite) before packing it into the jar ?

Alternatively, if those questions do not make sense, a hint where to learn more about "what's the purpose of a manifest inside a jar file" ?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 12 2009
Added on May 14 2009
21 comments
1,028 views