I need remove jarFile.jar
> /META-INF
folder.
First, I extract the original jarFile.jar
into temp/ folder
Then I delete META-INF/
And zip it again, no errors, but the file appears corrupt.
Anyone can help me?
EDIT:
public static void removeJarFiles(File jarFile, String[] files) throws IOException { File tempFolder = new File(jarFile.getParentFile(), "temp/"); tempFolder.mkdirs(); unZip(jarFile.getAbsolutePath(), tempFolder.getAbsolutePath()); // Decompress JAR // Delete files for (String file : files) { File f = new File(tempFolder, file); if (f.isDirectory()) { Util.deleteDir(f); } else { if (f.exists()) { f.delete(); } } } jarFile.delete(); // Delete OLD Jar // Re-Create JAR zipFolder(tempFolder.getAbsolutePath(), jarFile.getAbsolutePath()); }
If you remove META-INF from a jar then there is no MANIFEST.MF and so java -jar can't find the main class.
You can create jars without META-INF but when you are going to execute a jar a META-INF/MANIFEST.MF is required.
See http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html