Storyyeller / Krakatau

Java decompiler, assembler, and disassembler
GNU General Public License v3.0
1.95k stars 220 forks source link

How to decompile single class file? #31

Closed breezewish closed 1 year ago

breezewish commented 10 years ago
breezewish:lib breeswish$ python Krakatau/decompile.py ~/hello.class
Krakatau  Copyright (C) 2012-14  Robert Grosse
This program is provided as open source under the GNU General Public License.
See LICENSE.TXT for more details.

Attempting to automatically locate the standard library...
Found at  /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/jre/lib/rt.jar
processing target /Users/breeswish/hello, 1 remaining
Loading /Users/breeswish/hello
Traceback (most recent call last):
  File "Krakatau/decompile.py", line 147, in <module>
    decompileClass(path, targets, args.out, plugins, args.skip)
  File "Krakatau/decompile.py", line 88, in decompileClass
    c = e.getClass(target)
  File "/Users/breeswish/Development/java-decompiler-combination/lib/Krakatau/Krakatau/environment.py", line 26, in getClass
    result = self._loadClass(name, subclasses)
  File "/Users/breeswish/Development/java-decompiler-combination/lib/Krakatau/Krakatau/environment.py", line 60, in _loadClass
    raise ClassLoaderError('ClassNotFoundException', name)
Krakatau.error.ClassLoaderError: 
ClassNotFoundException: /Users/breeswish/hello
Storyyeller commented 10 years ago

You need to provide the exact name of the class (in this case Hello, not ~/Hello) and it has to have a path relative to the specified path that matches the class name.

python Krakatau/decompile.py -path ~ hello.class

Would likely do what you intended, though I don't have a Linux box to test at the moment.

breezewish commented 10 years ago

arguments become complicated and hard to decompile single class file without any limitations. Anyway it works :) Thank you.

Storyyeller commented 10 years ago

The command line interface for decompiling raw classfiles is pretty ugly. I'm not sure what the best thing to do there is. But in practice, I've found that you normally want to decompile an entire jar, which is much easier.

breezewish commented 10 years ago

Yep, but it would be better to provide a general interface :D

Storyyeller commented 1 year ago

I'm planning to support decompilation of lone classfiles in the v2 decompiler (if I ever manage to write that), so I'm going to go ahead and close this now.