Vim Tips Wiki

Decompile Java .class files automatically

Redirected from VimTip155

1,624pages on
this wiki
Add New Page
Talk0 Share
Tip 155 Printable Monobook Previous Next

created November 7, 2001 · complexity intermediate · author Lawrence Kesteloot · version 6.0

Here's a plugin to automatically decompile Java .class files as they're read in. Tweak the javap flags for what you want to see. I didn't post this as a script because it's too simple and it's really more useful for demonstrating how to read decompilable files (or other binary files that can be converted to text).

function s:ReadClass(dir, classname)
  execute "cd " . a:dir
  execute "0read !javap -c " . a:classname
  setlocal readonly
  setlocal nomodified

autocmd BufReadCmd *.class
  \ call <SID>ReadClass(expand("<afile>:p:h"), expand("<afile>:t:r"))


It doesn't work when package is used in java code.
class Foo


The question is how to save package information?

For jad:

au BufReadCmd *.class setl readonly nomodified | %!jad -p <afile>

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki