Use Emacs to edit compressed .ear and .war files

Home/General, Java/Use Emacs to edit compressed .ear and .war files

If you’re like me, you’ve often found yourself needing to change a setting, or view some information, buried deep inside a .ear or .war or .sar file. Well, you probably know that emacs can handle looking inside and editing files within a .tar or .jar file. Since .ear and .war files are just .jar files at their core, you can easily extend this feature to those file types.

Just add this to your ~/.emacs file:

(setq auto-mode-alist
(append
'(("\\.war\\'" . archive-mode))
'(("\\.ear\\'" . archive-mode))
'(("\\.sar\\'" . archive-mode))
auto-mode-alist))

And you’ll get something that look like this:

emacs hudson.war

emacs editing a war file

By | 2017-05-18T15:18:45+00:00 September 26th, 2007|General, Java|6 Comments

About the Author:

6 Comments

  1. Norman Richards October 21, 2007 at 11:12 pm - Reply

    I’ve been an emacs user for nearly 20 years, and I did not realize that you could edit a file inside a ZIP from within emacs. Thank you so much. :)

  2. Devon October 22, 2007 at 7:54 am - Reply

    Hey, no problem:)

  3. gavenkoa November 18, 2008 at 4:20 am - Reply

    Because i have

    (prefer-coding-system ‘utf-8-unix)

    also need

    (modify-coding-system-alist ‘file “\\.\\(war\\|ear\\|sar\\|egg\\)\\'” ‘no-conversion)

    to

    (add-to-list ‘auto-mode-alist ‘(“\\.\\(war\\|ear\\|sar\\|egg\\)\\'” . archive-mode))


    Regards!

  4. Yahya February 16, 2010 at 3:50 am - Reply

    Thanks. It is a great tool, that I’ve just discovered

  5. RDC October 25, 2010 at 3:41 am - Reply

    how can we replace any jar file from the ear file ? is it possible using emacs or any other way with out unpacking the ear …

    • Devon October 25, 2010 at 6:19 am - Reply

      RDC: I’m not sure…. You could run with an exploded ear I guess. I CAN edit contents of a jar/war that’s inside of a compressed ear using emacs, but as for replacing the entire file/archive, I’m just not sure.

Leave A Comment