title: Programmatically read Manifest.MF from JAR in an EAR
body: <p>I have to scan EARs to determine the version of one of its JARs, by reading the manifest...</p>
  
  <p>I happen to have something like this to read: MyApplication.ear/MyLibrary.jar/META-INF/Manifest.MF</p>
  
  <p>I can't figure how to do this the simplest way... i've been struggling with JarFile, JarInputStream, JarURLConnection,  so far no luck.</p>
  
  <p>Here's what i have at the time:</p>
  
  <pre><code>JarFile myEAR = new JarFile(urlOfMyEAR);
  JarEntry myJAR = myEAR.getJarEntry(libname);
  Attributes m = myJAR.getAttributes();
  System.out.println(m.getValue("Implementation-Version"));
  </code></pre>
  
  <p>but the <code>getAttributes()</code> returns <code>null</code>...</p>
  
  <p>I assume there's surely a complicated/thourough way to do it (by extracting the file or else), but I was hoping there's a simpler...</p>
  
  <p>Thanks for your help.</p>
  
  <p>EDIT: my own answer below...</p>