What if you have to decompile a huge jar file (like weblogic.jar) to debug a nasty issue? for a lot of closed source binary the source code is not always available, in this small post I will show you how to automate the de-compilation of java classes with a bit of bash magic.

 

First you’ll have to get the JAD decompiler if you don’t already have this tool in your development toolbox

wget
 www.varaneckas.com/sites/default/files/jad/jad158e.linux.static.zip
unzip jad158e.linux.static.zip

Unpack and decompile all class found in the jar file, replace the file weblogic.jar with any other jar file

jar 
-xf weblogic.jar && find . -iname "*.class" | xargs /path.to/jad -r 

Delete all files *.class from the current directory recursively

find . -type f -name *.class -exec rm {} \;

And rename all decompile .jad files to .java

find -name *.jad -exec rename 's/\.jad$/\.java/' {} \;

You can now repack the whole directory into a zip that you may deploy in your local maven repository or attached to weblogic.jar as source code in eclipse. I now just have to wish you good luck and happy debugging sessions!

Links

http://www.varaneckas.com/jad

comments powered by Disqus

You might like also

No Thumbnail was found
I’ve been&160; granted a free professional license of XDepend, thanks to Mat Huston, XDepend lead developer. XDepend is a static analysis tool for JAVA developers that provides 82 code metrics, several real-time code visualization panels, code base snapshots comparison, architectural and quality rules (edition and real-time validation). The tool is a frontend to support the Code Query Language (CQL) to query a code base the same way you would query a relational database. You can using CQL, write and design …
3556 Days ago
Tux Droid Plugin for Atlassian Bamboo continuous integration server
Tux Droid is a Linux wireless Tux mascot (210mm x 180mm x 140mm - with lowered wings) with a programmable interface, allowing it to announce events by its gestures and by ALSA driven sound. The events are detected by specific gadgets, which are handled by the Tux Gadget Manager. The Tux Droid supports Linux kernel 2.4 or later and needs a 800 MHz CPU and 128 MB RAM. It communicates by infrared to the USB port (1.1 or 2.0) and …
3771 Days ago
Tux Droid Plugin for Jet Brains TeamCity 4.0
Tux Droid is a Linux wireless Tux mascot (210mm x 180mm x 140mm - with lowered wings) with a programmable interface, allowing it to announce events by its gestures and by ALSA driven sound. The events are detected by specific gadgets, which are handled by the Tux Gadget Manager. The Tux Droid supports Linux kernel 2.4 or later and needs a 800 MHz CPU and 128 MB RAM. It communicates by infrared to the USB port (1.1 or 2.0) and …
3775 Days ago
Using Code Checker to improve your Java code (Part 1)
Code checker scans Java source code in your favorite IDE (I assume Eclipse :-)) There are basically of 2 types: On the fly code checker, as soon as you type a word or save a new document, it run and give a real time feedback Offline checker or so called static code analyzer that can be run during the build of your java components Why using a code guidelines checker? These tools are highly recommended across a team of different …
4122 Days ago
No Thumbnail was found
The version 8.0rc2 is available hereFreeMind is a premier free mind-mapping software written in Java. The recent development has hopefully turned it into high productivity tool. We are proud that the operation and navigation of FreeMind is faster than that of MindManager because of one-click "fold / unfold" and "follow link" operations. …
5221 Days ago
No Thumbnail was found
Maybe You do not know or have ever heard that there can be an alternative to notepad, wordpad, textedit, ultraedit, textpad ...and the list of text editor can be very long. I am using JEDIT since 4 years now and will never give it back. It is one of these Java application which demonstrate the portability and quality of Java software. (Mac OS X, OS/2, Unix/Linux, VMS and Windows)Open source, GNU General Public License, 7 years of development: jEdit is …
5242 Days ago
No Thumbnail was found
"RSSOwl collect data from RSS-compliant sites are called RSS readers or "aggregators." RSSOwl is such an application. It lets you gather, organize, update, and store information from any compliant source in a convenient, easy to use interface, save selected information in various formats for offline viewing and sharing, and much more. RSSOwl is also free of charge, fast, cross-platform, and unobtrusive. It's easy to install, easy to use, and easy to move." Azureus is a java bittorrent client. It provides …
5352 Days ago