I want to generate programtically a jar file in java. This works well when the input jar file has NOT been obfuscated. When I use an obfuscator on it, the first entry is no longer the manifest, so I can't generate a new file...
Here is my code:
JarInputStream input = new JarInputStream(getClass().getResourceAsStream("/obfuscated_jar.jar"));
JarOutputStream output = new JarOutputStream(new FileOutputStream("generated_jar.jar"), input.getManifest());
The line input.getManifest()
returns null because the manifest is not at the first place.
I've made some searches on it, and it looks to be a known issue with JarInputStream
. So here is my question: Is it possible to solve it? Like writing my own getManifest method or something?