tags:

views:

114

answers:

3

how can I decompile a jar and load it as a project in my Eclipse so I can modify the code ?

fyi I have googled jar decompiler. Looking for a guide or any insight on experiences with it.

A: 

http://bit.ly/ci7MXQ

JoelFan
oh wow ! thanks this is so helpful. how can I have not thought of finding a decompiler. </scarcasm>
Kim Jong Woo
Stack Overflow is not Twitter; you don't need to mask full URLs using short URL services...
BoltClock
A: 

Unless you also have the source code (either in the JAR, or separately), then the best you can do is to use a Java decompiler. Depending on how the code was compiled in the first place, this might generate source code which is significantly different to what the original author wrote (although functionally identical, of course). For example, certain optimizer options could result in loops being re-written and local variables being removed. Certain debug options could result in the names of local variables being removed, so the decompiler will have to invent (meaningless) names for them, etc.

I would also question whether what you want to do is legal. Generally, if a project is licensed for modification then its source code will be available and you won't need to do what you're proposing.

dty
I have purchased license but support has been minimal and lacks documentation. It's the least I could do.
Kim Jong Woo
That doesn't make it any more legal
dty
it's also not legal to rip off customers by providing a half assed product and going awol.
Kim Jong Woo
That STILL doesn't make it any more legal! Listen, I'm not judging you - I'm just pointing out one issue that you may not have thought of, that's all.
dty
A: 

I've used the Cavaj decompiler and it worked pretty well for me. You can just open up the jar file with any unzipping program like 7zip, .jar files are really just zip files. Then all you need to do is feed the .class files to Cavaj. The .class files are organized by package, so com.foo.Bar will be com/foo/Bar.class inside the .jar

Like Danny said, legality might be questionable depending on the situation. I've only ever used it to look at the source for an older version of an application I wrote but no longer had the source for.

jonescb
Java comes with a free decompiler. javap
dty
I just checked out javap and it looks like it only outputs the compiled code the VM executes. I don't know what compiled Java code looks like, but this sort of reminds me of either Assembly or BASIC. Cavaj while being extremely old, converts it back to plain Java.
jonescb
Oh yeah. Sorry, my bad. Then there are loads of freeware ones out there. Jad is something I've had success with before. My concern with the Cavaj product is that it only claims to run on Windows and claims it doesn't need Java installed. This implies that it is a native program, which might be OK or might not.
dty