File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Modifying Existing App w/o src Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Modifying Existing App w/o src" Watch "Modifying Existing App w/o src" New topic

Modifying Existing App w/o src

Daren Wilson

Joined: Jun 29, 2008
Posts: 16

My colleagues at work use an app written in Java. They'd like it modified in various ways - to show yellow lines here, some extra image processing there, respond to some mouse events that are currently ignored, etc. All we have are .jar files, no source. I asked the software provider, but they said nothing about source.

Is it a reasonable idea take on this project, or should i join the next cattle drive out of town? How would i go about modifying this app? Is it possible to modify a .jar, or is that something extreme no sane person would consider? A bytecode disassembler? Figure out the interface to a class and write my own replacement .jar files?

I'm many years experienced at programming in C++, assembly, raw binary blinking LEDs, expert at number crunching, graphics programming and all, and don't mind digging around at a low level. But i'm no expert at Java yet, need a cheat sheet to write HelloWorld ;-)

BTW, i love this site! Great design, well organized, a pleasure to visit.

Henry Wong

Joined: Sep 28, 2004
Posts: 20532

If you can get source from the vendor, that is definitely the way to go. It is also the best way to avoid complications, such as law suits. Or discontinuation of any support.

If you can't, you can get a decompiler to generate source code from byte codes, but... obfuscation is a possibility too. The vendor could have used an obfuscator on the bytecode to make it decompile to a mess -- assuming that it even works.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

It also may be possible to make the changes without modifying the source at all, but rather just replacing one or more of their classes with your own and/or adding classes.

For example, you can subclass existing classes and add behavior, or you can add event listeners onto existing GUI components. You can even use "bytecode engineering" to add behavior or modify existing behavior on the fly, either directly, or indirectly through the use of Aspect-Oriented Programming (AOP).

Doing any of these will take a certain amount of reverse engineering, and you may need to use a combination of techniques. But the decompile-modify-recompile angle is only one possibility, and not even necessarily the best one.

Now, you've posted this in the "Beginner's" forum, and say you're not a Java expert; unfortunately, I'm talking about some stuff that, while not necessarily advanced, required a good grasp of the lay of Java-land. Of course, we're always here to help.

[Jess in Action][AskingGoodQuestions]
Daren Wilson

Joined: Jun 29, 2008
Posts: 16

The software in question is freely available. It's used by scientists working with the Spitzer space telescope. It just needs a couple enhancements...

The idea of replacing a few chosen classes with my own might be the way to go. I might need to see a good example of how to do that in general. Reverse engineering is one of my better skills, and i've not dug into the workings of java very far yet, so this will be fun.
I agree. Here's the link:
subject: Modifying Existing App w/o src
jQuery in Action, 3rd edition