如何使用"closure-compiler"在java里面 [英] how to use "closure-compiler " inside the java
问题描述
我正在使用Google提供的闭包编译器.我在字符串变量中有JavaScript.需要在Java中使用闭包编译器来压缩字符串
I'm using closure-compiler which is provided by Google. I have JavaScript's in the string variable. need to compress the string using closure-compiler in java
我已经尝试了以下链接中的代码http://blog.bolinfest.com/2009/11/calling-closure-compiler-from-java.html
I already tried the code from the following link http://blog.bolinfest.com/2009/11/calling-closure-compiler-from-java.html
这是我使用的代码,其中"source"变量具有javascript的值
This is the code I used "source" variable has the value of the javascript
Compiler compiler = new Compiler();
CompilerOptions options = new CompilerOptions();
// Advanced mode is used here, but additional options could be set, too.
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
compiler.compile(source, options);
return compiler.toSource();
我在以下行中有错误: compiler.compile(source,options);
I have error in the following line: compiler.compile(source, options);
推荐答案
Compiler.complier()方法不需要2个参数,但需要3个参数.
Compiler.complier() method does not require 2 parameters but it requires 3 parameters.
Have a look at this link. You will understand the number and kind of parameters required for the method you are calling.
这篇关于如何使用"closure-compiler"在java里面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!