Support

Forums

Contact Me

How To decompile all classes from a jar

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

XDepend: static analysis tool for JAVA empower Code Query Language

I’ve been  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 your own rules and conventions for your code base.

XDepend

  • Analyses your java byte code, your test reports and your source files to extract structural information and 82 base metrics via static analysis.
  • Provides complementary and interactive views on the same information. A Tree-Map view helps you easily identify the big one from the small one. The dependency matrix, the graph view and the detailed view help you gain insight in your code base.
  • Has a Code Query Language (CQL) is a specific XDepend language, very similar to SQL, that helps you dynamically find what you are looking for.

What is also interesting me a lot is the possibility to make XDepend part of the Maven lifecycle, but that will be part of a new post. For now I am trying to understand the added value on our company software solution Innoveo Skye®

Watch the screen cast

Spring analyzed by XDepend

More to come later

Note: .Net is also having a similar tools NDepend, build on the same engine developed by Patrick Smacchia.

Tux Droid Plugin for Jet Brains TeamCity 4.0

tux-droid-linux-companionTux 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 for media detection it needs an internet connection. The mascot is driven by Atmel AVR RISC microcontrollers. From http://en.wikipedia.org/wiki/Tux_Droid

TeamCity is a Java-based build management and continuous integration server from JetBrains, creators of IntelliJ IDEA and ReSharper.

 

 

 

 

Read more: Tux Droid Plugin for Jet Brains TeamCity 4.0

Tux Droid Plugin for Atlassian Bamboo continuous integration server

tux-droid-linux-companion

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 for media detection it needs an internet connection. The mascot is driven by Atmel AVR RISC microcontrollers. From http://en.wikipedia.org/wiki/Tux_Droid

 

Bamboo is a continuous integration server from Atlassian Software Systems, the makers of JIRA, Confluence and Crowd. Bamboo is free for philanthropic and open-source projects. Academic and commercial organizations are charged based on type of license. Some other features of Bamboo are its unlimited build plans and unlimited projects that provide instant feedback and a platform to collaborate with other team members for build projects, and its ability to run distributed builds. It integrates with existing development tools, and it can be integrated with popular source code systems.

With this plugin

You can notify your Tux Droid with your TeamCity build results!

After login you can find the new notificator Tux Droid in your notification settings. You need your Tux Droid server IP and port  to connect your Tux to Bamboo. After you have saved the parameters you can configure your individual notification settings for just all projects/specific projects/build failures/...

Each registered User can customize Tux Droid messages or choose different Attitunes.

 

Some useful resource how to develop a Bamboo plugin with Maven 2

Plugin will appear soon at

http://tuxdroid-bamboo.waltercedric.com/

Note you may be interested by the TeamCity continuous integration server version at http://tuxdroid.waltercedric.com/

Using Code Checker to improve your Java code (Part 1)

coding.guidelines

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 developers for the following reasons:

  • These tools are highly configurable and can be made to support almost any coding standard.
  • Ideal for projects that want to enforce a coding standard (ideally where not all developer code the same way)
  • Ease your debugging and maintenance costs by making the code more readable: developers do not have to worry about
    deciphering individual coding styles when working on a piece of code they did not write.
  • They can detect possible bugs or dangerous coding behavior - empty try/catch/finally/switch statements
  • Detect dead code - unused local variables, parameters and private methods
  • Sub optimal code - wasteful String/String Buffer usage
  • Overcomplicated expressions - unnecessary if statements, for loops that could be while loops
  • Duplicate code - copied/pasted code means copied/pasted bugs
  • Find class design problems, bug patterns like double checked locking.

They give an immediate "objective" feedback and help developers recognize where they have been excellent or lazy;

It gives team leader, an opportunity to study the code, design and team from a different perspective; and by slicing off
whole classes of faults, You can concentrate more on design shortcomings.

Read more: Using Code Checker to improve your Java code (Part 1)

Donations

Thank You for supporting my work