I have to scan EARs to determine the version of one of its JARs, by reading the manifest...
I happen to have something like this to read: MyApplication.ear/MyLibrary.jar/META-INF/Manifest.MF
I can't figure how to do this the simplest way... i've been struggling with JarFile, JarInputStream, JarURLConnection, so far no luck.
Here's what i have at the time:
JarFile myEAR = new JarFile(urlOfMyEAR);
JarEntry myJAR = myEAR.getJarEntry(libname);
Attributes m = myJAR.getAttributes();
System.out.println(m.getValue("Implementation-Version"));
but the getAttributes()
returns null
...
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...
Thanks for your help.
EDIT: my own answer below...