• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java Decompiler

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I like to retrieve java file from its class file. Can you suggest me any standard java decompiler available?
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a decompiler 'javap' that's part of the JDK. It sounds like you want a disassembler to actually attempt to generate source code from a class file. I don't know of a good one but be warned the code generated isn't going to be something nice, elegant or documented.
 
Anjana Ravindran
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes, i like to get source code from the class file.

I heard that decompiler wont generate the code nice.
But i need it because i want to check some data in old java file. Unfortunately, i lost my old java file and have only class file of it. i want to compare both the versions.

One more help required
how to make use of javap to get the source code?

i tried this
javap -classpath c:\fsdsbatch.jar;c:\lib\msbase.jar;c:\lib\mssqlserver.jar;c:\lib\msutil.jar;c:\ojdbc14_g.jar;c:\JdbcClassesTA20.jar; fsdsbatch.util.FsdsSqlServerConnection

and it prints only class members. Cant i see my whole source code?
 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can try :-

jcavaj

DJ Java Decompiler

List of decompilers which use JAD

Comments are not compiled into bytecode so they are lost, and inner classes are not handled very well, but you can easily reformat the code using an IDE.

regards
Jason
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and of course all variable and parameter names are lost as well, and method code will be different from the original depending on compiler settings used.

Also remember that decompiling code not created by yourself is likely to be a violation of the license under which you're using that code.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Variable and method names will be OK if the original code was compiled using the debug flag, though. Jode (on SourceForge) does a good job at decompiling. javap is just a disassembler - it will show you the Java bytecodes, but it can't recover source code.
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We use JAD and JADClipse Eclipse plugin pretty happily. Every once in a while it fails to fully decompile. I don't know why.
 
Ken Blair
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I seem to have reversed decompiler and disassembler in my post. Oops.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic