SOLVED: How to read MANIFEST.MF from plugin

A

Albrecht Scheidig

Hi,

here is a way to access "your" manifest, i.e. the manifest of the jar
your class is loaded from. It only works for SunPlugin. In other cases
you may have another ClassLoader not supporting a public
findResource-method. The always public getResource unfortunatly
prefers to return resources returned by the parent's getResource if it
is not null. That's why you would get the manifest of rt.jar. Is there
any good reason to revert the principle 'local hides global' in case
of getting resources? Anyway, here it is:

import java.util.jar.Manifest;
import sun.applet.AppletClassLoader;
....
AppletClassLoader cl = (AppletClassLoader)
getClass().getClassLoader();
URL manifest_url = cl.findResource("META-INF/MANIFEST.MF");
Manifest manifest = new Manifest(manifest_url.openStream());

Yours,
Albrecht
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,044
Latest member
RonaldNen

Latest Threads

Top