some handy emacs code

Tom Tromey
Wed Aug 6 20:18:00 GMT 2003

For those of you using Emacs, here's some handy code I wrote for
looking inside .jar files.

Put this in .emacs, and then when visiting a .jar or .zip file, you
can use "?" to run jcf-dump on the class.


(defun tjt-view-class-file ()
  (if (eq archive-subtype 'zip)
      (let* ((descr (archive-get-descr))
	     (ename (aref descr 0))
	     (iname (aref descr 1))
	     ;; strip ".class"
	     (class (substring iname 0 -6)))
	(if (string-equal (substring iname -6) ".class")
	    (shell-command (concat "jcf-dump -c -I"
				   " "

(add-hook 'archive-mode-hook
	   (lambda ()
	     (define-key archive-mode-map "?" 'tjt-view-class-file))))

More information about the Java mailing list