2014-03-05 82 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