I know you can navigate the contents of an archive with emacs. Is there a way you can edit those files in place and write the archive transparently?. Currently, I navigate into the archive, write the file to a temp directory, and the use the java jar command to add the file back into the archive. Its a little bit of pain.
P.S. I know there are few use cases where you'd want to do this, but I've inherited a platform that I can't readily modify where I have to cope with this limitation in the short term.
JAR files are just ZIP files. Use a tool like WinZip to extract all the files from the JAR, replace the . class file with yours, recreate the ZIP file using e.g. WinZip, rename it to . jar, overwrite the original JAR file.
Yes, it just works. Did you try it?
I grabbed a jar file that contained a text file and some java code that would print it out. I edited the txt file within the .jar and saved the text file. It did exactly what I would expect.
EDIT- When saving the archive make sure you use C-x C-s
In emacs-23.2 (not 23.1 or 23.3) this doesn't "just work" on Windows due to a bug. Instead it just writes caution: filename not matched: "<internal path>
.
One solution is to simply upgrade to 23.3.
To fix the bug in emacs-23.2, open $EMACS_HOME/lisp/arc-mode.el
and replace:
(if (equal (car archive-zip-extract) "unzip")
(shell-quote-argument name)
name)
with:
name
and recompile:
M-x byte-compile-file $EMACS_HOME/lisp/arc-mode.el
This answer comes from the original emacs bug report.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With