Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Java API to read, interpret, and write Java manifest files (MANIFEST.MF)? [closed]

Tags:

java

manifest

I work with the ATG Dynamo platform - a Java based platform that uses manifest files to define many configuration details of its modules.

I would like to build some tools and scripts - say, ANT scripts or Maven plugins - to programmatically manipulate these files. Specifically, I want to be able to read existing files and perform some tasks based on the contents on one hand, and to generate new manifest files as part of my build process on the other.

The MANIFEST.MF format seems to be very simple, though there are some rules about line length and white space, so I am sure I can hand-code a lot of this. However, it would be really useful if there already exists an API to to read and write such files according to the spec.

Any suggestions?

like image 737
Vihung Avatar asked Dec 08 '25 21:12

Vihung


1 Answers

Use JarFile#getManifest(). It gives you an instance of Manifest, providing several convenience methods to access the attributes.

JarFile jarFile = new JarFile(file);
Manifest manifest = jarFile.getManifest();
// ...
like image 131
BalusC Avatar answered Dec 10 '25 11:12

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!