2014-03-05 47 views
0

我有一个项目,将.class文件转换为.java文件,在研究期间,我发现Proycon是一个java库,可以帮助做到这一点。不幸的是,我找不到Proycon的任何适当的文档。任何有经验的人使用它,如果是的话,请告诉我用哪种方法将.class转换成.java文件并将其打印到控制台?反编译.java文件使用Proycon

+0

当时的[与维基主页和作者的联系方式] (https://bitbucket.org/mstrobel/procyon)不够? –

+0

@JasonC我认为我的谷歌找不到链接,你有链接吗? – droidev

+0

点击我评论中的链接...这也是第一个谷歌“procyon反编译器”的结果。 –

回答

1

JD-core-java https://github.com/nviennot/jd-core-java是jd-core的薄包装。自述文件显示如何在您的项目中使用它。

/* Returns the source of SomeClass from compiled.jar as a String */ 
new jd.core.Decompiler.decompile("compiled.jar", "com/namespace/SomeClass.class"); 

/* 
* Returns the sources of all the classes in compiled.jar as a Map<String, String> 
* where the key is the class name (full path) and the value is the source 
*/ 
new jd.core.Decompiler.decompile("compiled.jar"); 

/* 
* Returns the number of classes decompiled and saved into out_dir 
*/ 
new jd.core.Decompiler.decompileToDir("compiled.jar", "out_dir"); 
+0

我已经实现了这个方法,它引发了一个异常“java.lang.UnsatisfiedLinkError:Can not load library” – droidev

+0

这是由于一些缺少的库。 请参阅下面的链接作为故障排除指南。 http://stackoverflow.com/questions/1403788/java-lang-unsatisfiedlinkerror-no-dll-in-java-library-path – Chamil

+0

问题是给定的github源代码是Linux的包装,我在windows中工作,做你有Windows包装? – droidev

0

使用该闪客最好是我使用procyon-decompiler-0.5.30.jar从到位桶repo转换。

如果你需要编译一个或多个罐子,请他们复制到文件夹,然后运行:

%JAVA_HOME%\bin\java -jar c:\procyon\procyon-decompiler-0.5.30.jar -o . *.jar 

在上面的命令我指定的完整路径procyon罐子,和-o .将输出设置为当前文件夹。

可以说,我要检查sentry-logback-1.5.4.jar,运行上面的命令后,我会用以下结构的工作文件夹结束:

sentry-logback-1.5.4.jar 
[io] 
    `-- [sentry] 
      `-- [logback] 
       `-- SentryAppender.java