Reputation: 711
I am trying to decompile a file using Storyyeller/Krakatau decompiler. I have already downloaded the relevant file and placed it inside a folder. I tried decompile the file using below syntax using command prompt.
=== Decompilation ===
Usage:
python Krakatau\decompile.py [-nauto] [-path PATH] [-out OUT] [-r] [-skip]
target
PATH: An optional list of directories, jars, or zipfiles to search for
classes in. Krakatau will attempt to automatically detect and add the
jar containing core language classes, but you can disable this with
the -nauto
option. For multiple jars, you can either pass a semicolon
seperated list of jars or pass the -path
option multiple times.
OUT: Directory name where source files are to be written. Defaults to the current directory. If the name ends in .zip or .jar, the output will be a zip file instead.
-r: Decompiles all .class files found in the directory target (recursively)
-skip: Continue upon errors. If an error occurs while decompiling a specific method, the trace back will be printed as comments in the source file. If the error occurs while decompiling at the class level, no source file will be emitted and an error message will be printed to the console.
target: Class name or jar name to decompile. If a jar is specified, all
classes in the jar will be decompiled. If -r
is specified, this should
be a directory.
But I always get errors.I don't understand the above syntax.
Please explain this syntax
python Krakatau\decompile.py [-nauto] [-path PATH] [-out OUT] [-r] [-skip]
target
using a simple example.
Upvotes: 4
Views: 6943
Reputation: 39451
The easiest and normal way to decompile with Krakatau is to decompile a jar.
Say you have a jar file named Luyten.jar
in the current directory and you want to decompile every class in the jar and output it to the directory temp
. Then you'd do something like
pypy -O Krakatau\decompile.py -skip -out temp Luyten.jar
Depending on whether you have JDK installed and where, you may need to explicitly pass the location of the jre in the path argument. For example
pypy -O Krakatau\decompile.py -skip -out temp -path "C:\Program Files (x86)\Java\jre7\lib\rt.jar" Luyten.jar
If you want to decompile a specific class within the jar, you can add the jar to the path and specify the classname. If you need to specify a path to rt.jar as in the previous example, you can pass the -path
argument multiple times or a single time separated by semicolons. For example to decompile only the class com.beust.jcommander.FuzzyMap$IKey,
pypy -O Krakatau\decompile.py -skip -out temp -path Luyten.jar com.beust.jcommander.FuzzyMap$IKey
You can also decompile classfiles that are outside of a jar, but it's a lot more annoying, because you have to make sure the directory layout is correct. You need to specify the directory that is the root relative to where the classes will be found.
For example, suppose you have a classfile located at ./Foo/Bar/com/beust/jcommander/FuzzyMap$IKey.class
pypy -O Krakatau\decompile.py -skip -out temp -path Foo/Bar com.beust.jcommander.FuzzyMap$IKey
In this case, the directory has to match the fully qualified classname exactly. A common mistake is to try to decompile with the wrong root directory. The nice thing about jars is that having the correct directory structure is automatic.
Upvotes: 5