OS/X Java MicroTip: Decompile Java class from the Finder
August 11th 2010 · Java , Mac ComputerHere’s another micro-tip. I needed to decompile a Java class to step through for debugging. But I wanted to pick and choose classes from the Finder. No problem, this is OS/X and Automator is your friend.
If you don’t already have it, download JAD (Java Decompiler) from http://www.varaneckas.com/jad.
Then open up Automator and create a new Service. Tell Automator that the service will receive only selected files or folders. You can use any application or just Finder, your call. If you like, filter out only the class files. Then comes the real work. Specify the zsh shell and give it this command line:
jad -lnc -o -d `dirname $1` $1
You’ll have to specify the full path to the jad executable if it’s not in your path. The -lnc
tells JAD to add original line numbers as comments – very helpful when debugging. The -o tells
JAD to overwrite output files without asking. And the -d tells JAD where to put the decompiled
files. In our case we’re only allowing a single file at a time and we’re putting the decompiled
file into the same directory as the original class file.
When you’re done, it should look something like this:

Save the workflow service and name it whatever you like, in my case I named it
‘Decompile Java Class’. Close any open Finder windows and re-open them. Now when you right click
on a file you’ll see ‘Decompile Java Class’ as an option in the Services menu. Select it and
JAD will decompile your selected class file into a .jad file.
to the Safari button bar.
When you click it, a toolbar slides down and the current web page goes into edit mode. You
can draw on the page using a pencil tool (in green, red or blue), you can draw using a
highlighter (in yellow, purple or blue), you can change the text on the page or you can put
sticky notes with text on top of the page.