我想從我的Java代碼中使用Google Closure Compiler API。函數compile()接收原始源代碼,並將編譯的源代碼返回到String中。在Google App Engine中使用Google Closure的「compiler.jar」
此代碼將在Google App Engine中運行,但是當我部署並運行它時,會出現「服務器錯誤」。沒有調用下面的函數,我沒有得到任何錯誤。在編譯時,我得到警告「compiler.jar在服務器的類路徑上不可用」。 Compiler.jar是我從Closure Compiler項目網站下載的庫。
任何想法如何解決這個問題?
萬分感謝,
import com.google.javascript.jscomp.*;
public static String compile(String code)
{
com.google.javascript.jscomp.Compiler.setLoggingLevel(Level.INFO);
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
CompilerOptions options = new CompilerOptions();
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
JSSourceFile js = JSSourceFile.fromCode("input.js", code);
WarningLevel.QUIET.setOptionsForWarningLevel(options);
compiler.compile(null, js, options);
return compiler.toSource();
}
「服務器錯誤」僅僅是個500級的用戶顯示 - 堆棧跟蹤是在你的服務器日誌(在管理控制檯中,在日誌)。那顯示了什麼? – 2012-03-27 09:25:08