SOLVED: How to read MANIFEST.MF from plugin

Discussion in 'Java' started by Albrecht Scheidig, Feb 12, 2004.

  1. 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
     
    Albrecht Scheidig, Feb 12, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. PilotYid
    Replies:
    1
    Views:
    674
    Andrew Thompson
    Oct 31, 2005
  2. Marcin Cenkier
    Replies:
    1
    Views:
    5,498
    Marcin Cenkier
    Apr 12, 2006
  3. Jimmy
    Replies:
    0
    Views:
    543
    Jimmy
    Mar 15, 2007
  4. Replies:
    1
    Views:
    768
  5. Michael Bacarella
    Replies:
    26
    Views:
    1,416
    harri
    Nov 20, 2007
Loading...

Share This Page