Search code examples
javadecompiling

Decompiling jas/ClassEnv created .class files from inside a Java application


My java application creates .class files using jas ClassEnv. I need to be able to decompile these .class files and turn the contents into a string (so that it can be displayed in TextArea). All of the decompilers I have found are standalone programs, are there any integrated java libraries that can do this decompilation? Or Is there anyway I can get a string representation from the ClasseEnv object?


Solution

  • Here are some options I found:

    1. back2code
    2. Soot + Dava
    3. jclazz
    4. jdec
    5. jode
    6. dcompiler
    7. jreversepro

    Note: I have not used any of the above myself, so you will have to check if they support features you require, or if they are mature enough for your needs

    Note: although some of the listed options are seemingly standalone programs, all that require Java to be executed (that is, you are not running an .exe for example -- but do check inside .bat/.sh scripts), you can invoke from your program: just add the appropriate .jar files to your application's classpath and you can access all the classes in them from within your program -- at the minimum you will be able to call the main() method in the default class of the .jar with the appropriate parameters. You might need to open a file (where the source of the decompiled .class is extracted) to access the source as a string in your program.