Search code examples
javareflectionjarreflections

jarInputStream.getManifest() is null


When I upload a jar file to a servlet and try reading its manifest. jarStream.getManifest() returns null..

JarInputStream jarInputStream = new JarInputStream(inputStream);

Manifest mf = jarInputStream.getManifest();

While the same jar when I read as JarFile providing an absolute path, I get the manifest of the jar..

I need to read the manifest of the jar file at runtime.. when it is uploaded..

Any suggestions are most appreciated..


Solution

  • By packaging the jar using ant script to provide the custom attributes to the manifest helped to get the manifest successfully.

    previously I was packaging the jar using eclipse>export>java>java archive where the manifest was default, editing the manifest of this exported jar seemed to be the cause of the problem.

    Thanks to @EJP and @Burkhard for quick responses to my query.