File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes How to decompile a class file? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to decompile a class file?" Watch "How to decompile a class file?" New topic
Author

How to decompile a class file?

Bill Pearce
Ranch Hand

Joined: Sep 19, 2000
Posts: 53
Hi all,
I was wondering if any of you could point me in the right direction. I have a class file that I would like to get the source code from. How do I go about this? I know there is no way built in to the JDK, but have heard that it is an easy thing to do.
Any help appreciated.
Bill
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

This is a tricky ethical question.

If you are trying to decompile a package of classes that you paid money for, and want to use the source to write your own stuff and resell it, then perhaps this is not such a good idea.

But if you are just satisfying curiosity, then go to www.download.com and in the search box at the top right, search for 'java decompiler'

They have downloads for mp3 piracy software, why not java class files, right?

Morality is for the rich?
Bill Pearce
Ranch Hand

Joined: Sep 19, 2000
Posts: 53
Thanks, Mike. I am trying to debug something we purchased from a vendor. It's legit, I promise.
For anyone who might benefit, I found DJ Java Decompiler at download.com. Enter the keywords as Mike suggested and you'll find it. It is quick and easy to use. Do not use it for evil.
Bill
rani bedi
Ranch Hand

Joined: Feb 06, 2001
Posts: 358
Lot of decompilers are freely available.
Decafe Decompiler http://decafe.hypermart.net/
DJ Java Decompiler http://members.fortunecity.com/neshkov/dj.html
Class Cracker http://www.tip.net.au/~mayon/classcracker/

Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Something I got in the mail applies to this thread.

I subscribe to the developerWorks newsletter, check out this link from IBM.
http://www-106.ibm.com/developerworks/library/j-obfus/?n-j-5311
Cynthia Yao
Ranch Hand

Joined: Nov 06, 2000
Posts: 92
I used mocha and jad before to view some source code on applet, and it is not very easy to understand, but was fun. Thanks Mike, that article is very interesting
Steven YaegerII
Ranch Hand

Joined: May 31, 2000
Posts: 182
I'm curious, can changes in file associations cause an error? After installing DJ_Decompiler, my .class files changed from using an MSNotePad icon to using a different icon. My .java files did not change icons, but I cannot open either of them now, without getting a "Program Not Found" error telling me that I need DJ's .exe file to open a .class or .java file. I'm using WIN98se. Anyone encounter this before?
SteveII
SandeepKumar
Greenhorn

Joined: Jul 09, 2001
Posts: 3
u can download mocha.zip and give the path to this zip file in your classpath then run the command
java mocha.Decompiler yourclass.class
this will generate a yourclass.mocha file
that is nothing but your java file
other way around is open your class file in some java IDE like JBuilder , VisualCafe , VisualAge
and you can see the code
Lucas Richardson
Ranch Hand

Joined: Jul 08, 2001
Posts: 32
To fix that, from any explorer window, select the view menu, and then folder options. Go over the the "file types" tab, and highlight the type of file you're looking for. Press the edit button, and another window pops up. Highlight "Open" under Actions, and press edit.. . That will then allow you to select what application is set to open that paticular file type.
Alan Watts
Greenhorn

Joined: May 14, 2001
Posts: 28

On obfuscation now. Does anyone know of an index of java methods that are susceptible to being mucked up by the popular obfuscators? By mucked up I mean prevented from working as Sun intended during runtime.
Cheers
Alan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to decompile a class file?