• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Converting class code back to source code

 
Doug Wolfinger
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please help! I ran a program and redirected the output to a flat file, but I named that file the same as the program name. So I overwrote my program, Selection.java, with the text of the output by saying java Selection > selection.java. Anyone know the DOS command to convert the .class file back to the .java file?
EDIT: I'll try to find a decompiler at downloads.com. Isn't javap supposed to do this? It does something, but it doesn't create the .java file when I run it in \bin.
Thanks,
Doug
[ November 18, 2002: Message edited by: Doug Wolfinger ]
[ November 18, 2002: Message edited by: Doug Wolfinger ]
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try a google search for "java decompiler".
I've used DJ before
 
Marilyn de Queiroz
Sheriff
Posts: 9064
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javap is not a decompiler.
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mocha
 
Monty Ireland
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just downloaded and used mocha.
it is a basic tool.
it is a very cool tool.
i wish i had it a few year ago.

what i did to get mocha to work
1. downloaded mocha.zip
2. copied mocha.zip to c:\jdk1.3.1\lib
3. add c:\jdk1.3.1\lib\mocha.zip to my CLASSPATH
CLASSPATH=.;c:\jdk1.3.1\lib\mocha.zip
4. from a dos prompt i typed
java mocha.Decompiler -v -o test63.class
*. a text file called test63.mocha is created
that's it...
[ November 20, 2002: Message edited by: Monty Ireland ]
 
Doug Wolfinger
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, all. I have a beta Mocha installed but can't get it to work, so I used DJ. The decompilation was very pleasant but I noticed some disturbing things afterwards. For one thing, I couldn't get into my c:\ where the executable was located after the decompilation. It was alarming. The software locked up the c:\ somehow. So I closed Win Explorer and everything was fine when I reopened it. And I noticed that all class files had the DJ icon. I decided to get rid of it, and deleted the DJ files that made all the class files associate with it.
I didn't realize the source code would be neatly formatted by the decompiler, so that was a nice surprise.
If the new version of Mocha works I might go with that; it operates from the dos command line, so it should be less obtrusive.
[ November 19, 2002: Message edited by: Doug Wolfinger ]
 
Igor Ko
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try to find "jad" java decompiler
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Igor Ko:
try to find "jad" java decompiler

Jad's great -- very easy to use,
http://kpdus.tripod.com/jad.html
install it, put it in your %PATH% and call jad someClass.class and *poof* it write a someClass.jad for you. -- Just make sure you check out the known limitations of the product and realize you'll lose all comments from the code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic