问题
Anybody got any Idea why this error appears?
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(Z)V
at com.google.common.collect.Lists.computeArrayListCapacity(Lists.java:105)
at com.google.common.collect.Lists.newArrayList(Lists.java:98)
at com.google.javascript.jscomp.ComposeWarningsGuard.<init> (ComposeWarningsGuard.java:83)
at com.google.javascript.jscomp.CompilerOptions.<init>(CompilerOptions.java:791)
Code
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import com.google.javascript.jscomp.CompilationLevel;
import com.google.javascript.jscomp.CompilerOptions;
import com.google.javascript.jscomp.Compiler;
import com.google.javascript.jscomp.SourceFile;
public class MyJavaScriptCompressor {
private Compiler cloJsCompressor;
public MyJavaScriptCompressor() {
}
public String closureCompress(File source) {
CompilerOptions opt = new CompilerOptions();
int mode = 1;
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel( opt );
Compiler.setLoggingLevel(Level.OFF);
cloJsCompressor = new Compiler();
cloJsCompressor.disableThreads();
List<SourceFile> externs = Collections.emptyList();
List<SourceFile> inputs = Arrays.asList(SourceFile.fromFile(source));
cloJsCompressor.compile( externs, inputs, opt );
return cloJsCompressor.toSource();
}
}
build path includes
compiler.jar
jsoup.jar
yuicompressor.jar
how can i get rid of it?!
edit:
the error appears in this line:
CompilerOptions opt = new CompilerOptions();
回答1:
Solved..
.classpath in the project root of eclipse was missing that line:
<classpathentry kind="lib" path="lib/compiler.jar"/>
i dont know -why- eclipse was not able to fix that automatically..
来源:https://stackoverflow.com/questions/19818215/compileroptions-nosuchmethoderror-com-google-common-base-preconditions-checkar