Is there a quick way to delete a file from a Jar / war without having to extract the jar and recreate it?
zip -d file.jar unwanted_file.txt
jar is just a zip file after all. Definitely much faster than uncompressing/recompressing.
How do I update one file in a jar without repackaging the whole jar?
-C
is changing the local directory, and is looking for hi.png
there. It's not controlling where you're trying to inject it into the JAR file.
I would try making a new directory called images
, moving your local hi.png
into that, making images
a child directory of your current working directory, then just run this:
jar uf myfile.jar images\hi.png
Deleting files using a .jar
// Deletes all files and subdirectories under dir.
// Returns true if all deletions were successful.
// If a deletion fails, the method stops attempting to delete and returns false.
public static boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
How do I unsign a jar?
I don't know the answer, but here is what I would do:
- Unzip the jar file or files in question (jars are just zips)
- Look in the META-INF directory for something that was not MANIFEST-MF.
- Delete that stuff.
- Open the MANIFEST-MF and remove stuff that looked like it was signature related.
- rejar.
Related Topics
Create Directory with Write Permissions for the Group
Java.Lang.Unsatisfiedlinkerror in Linux
File Not Found Exception When Reading File from Linux Extreme Vps
Why Is 08 Not a Valid Integer Literal in Java
How to Call Method in Jar File with Terminal
How to Resolve "Could Not Find Jni", Building Opencv on Raspberry Pi
What Are the Main Benefits of Using Mono Over Java
What Could Be Reason for "Prism-Es2 Error:Gl_Version (Major.Minor) = 1.4"
The Full Pathname of a Jdk Installation for Oracle SQL Developer
Change File Owner Group Under Linux with Java.Nio.Files
Issues with Corba Communication
Shuffle Multiple Files in Same Order
Eclipse 3.6 Helios for Ubuntu 10.10
In Java, "5/0" Statement Doesn't Fire Sigfpe Signal on My Linux MAChine, Why
Commportidentifier.Getportidentifiers with Zero Ports on Linux
Java Randomaccessfile.Java Under Linux Not Working Correctly