How to reverse engineer a jar file

Hi:I have a jar file containing a java class. Is there a way I can reverse engineer the .jar or .class to get the .java (source code) file ?Thanks.
[168 byte] By [Nish_Ba] at [2007-11-27 5:02:59]
# 1
jar xvf myJar.jar
ktm5124a at 2007-7-12 10:21:02 > top of Java-index,Java Essentials,Java Programming...
# 2
ask the developers for the source code?!
S_i_m_ua at 2007-7-12 10:21:02 > top of Java-index,Java Essentials,Java Programming...
# 3
Apparently I wrote the jar file and I have misplaced the source code!!!
Nish_Ba at 2007-7-12 10:21:02 > top of Java-index,Java Essentials,Java Programming...
# 4
> jar xvf myJar.jarThis unjars the jar file and lays down its contents.I need to get the .java file or the source code from either the .jar or the .class.Is there a way to do this?
Nish_Ba at 2007-7-12 10:21:02 > top of Java-index,Java Essentials,Java Programming...
# 5
Once you have the class files you can run them through a decompiler but this won't provide a perfect .java file.
floundera at 2007-7-12 10:21:02 > top of Java-index,Java Essentials,Java Programming...
# 6

It will provide a good enough stab at the original. It's nothing nearly as bad as disassembly.

But yeah, there's a Java decompiler called mocha that decompiles bytecode. You can also use GUIs like Eclipse or FrontEnd Plus to decompile it.

Mocha makes me wonder whether there were any noble intentions at all in Sun making Java open-source :P

ktm5124a at 2007-7-12 10:21:02 > top of Java-index,Java Essentials,Java Programming...
# 7

why would you wonder?

You have the source to the Java class libraries already. In fact they've always been shipped with the JDK...

The sole reason to "open source" Java when it already was (the source has always been available for study and for several years now there's been a system where you could submit bugfixes as well, which is essentially what any open source project is in reality) was politics, trying to get the Linux zealots to ship Java with their distributions.

jwentinga at 2007-7-12 10:21:02 > top of Java-index,Java Essentials,Java Programming...
# 8

> It will provide a good enough stab at the original.

> It's nothing nearly as bad as disassembly.

>

> But yeah, there's a Java decompiler called mocha that

> decompiles bytecode. You can also use GUIs like

> Eclipse or FrontEnd Plus to decompile it.

>

> Mocha makes me wonder whether there were any noble

> intentions at all in Sun making Java open-source :P

Yes, thanks.

I was able to get JAD to decompile my jar.

Nish_Ba at 2007-7-12 10:21:02 > top of Java-index,Java Essentials,Java Programming...