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
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