How can I open Java .class files in a human-readable way?

后端 未结 17 1985
傲寒
傲寒 2020-11-28 18:09

I\'m trying to figure out what a Java applet\'s class file is doing under the hood. Opening it up with Notepad or Textpad just shows a bunch of gobbledy-gook.

Is the

相关标签:
17条回答
  • 2020-11-28 19:05

    jd-gui is the best decompiler at the moment. it can handle newer features in Java, as compared to the getting-dusty JAD.

    0 讨论(0)
  • 2020-11-28 19:05

    As pointed out by @MichaelMyers, use

    javap -c <name of java class file> 
    

    to get the JVM assembly code. You may also redirect the output to a text file for better visibility.

    javap -c <name of java class file> > decompiled.txt
    
    0 讨论(0)
  • 2020-11-28 19:08

    You want a java decompiler, you can use the command line tool javap to do this. Also, Java Decompiler HOW-TO describes how you can decompile a class file.

    0 讨论(0)
  • 2020-11-28 19:10

    If you don't mind reading bytecode, javap should work fine. It's part of the standard JDK installation.

    Usage: javap <options> <classes>...
    
    where options include:
       -c                        Disassemble the code
       -classpath <pathlist>     Specify where to find user class files
       -extdirs <dirs>           Override location of installed extensions
       -help                     Print this usage message
       -J<flag>                  Pass <flag> directly to the runtime system
       -l                        Print line number and local variable tables
       -public                   Show only public classes and members
       -protected                Show protected/public classes and members
       -package                  Show package/protected/public classes
                                 and members (default)
       -private                  Show all classes and members
       -s                        Print internal type signatures
       -bootclasspath <pathlist> Override location of class files loaded
                                 by the bootstrap class loader
       -verbose                  Print stack size, number of locals and args for methods
                                 If verifying, print reasons for failure
    
    0 讨论(0)
  • 2020-11-28 19:12

    you can also use the online java decompilers available. For e.g. http://www.javadecompilers.com

    0 讨论(0)
提交回复
热议问题