问题
I need to call Closure Compiler from a .bat file passing a flag language_in=ECMASCRIPT5
I am using the following script but I receive an error
java.lang.classnotfoundexception: com.google,javascript.jscomp.SourceFile
I would like to know:
- When I omit the flag code compile fine, so am I passing correctly the flag?
- Could you provide me more information about this error?
java -Xms256m -Xmx256m -cp "%~dp0../shrinksafe/js.jar";"%~dp0../closureCompiler/compiler.jar --language_in=ECMASCRIPT5";"%~dp0../shrinksafe/shrinksafe.jar" org.mozilla.javascript.tools.shell.Main "%~dp0../../dojo/dojo.js" baseUrl="%~dp0../../dojo" load=build %*
回答1:
As stated on the documentation:
(ClassNotFoundException) Thrown when an application tries to load in a class through its string name using:
- The forName method in class Class.
- The findSystemClass method in class ClassLoader .
- The loadClass method in class ClassLoader.
What I think it's happening, due to the fact the code works when you omit the flag, is that the variable ECMASCRIPT5
is defined inside the compiler.jar, which you might not be including in the classpath.
You could try placing compiler.jar to your WEB-INF/lib in order for it to be deployed with your application and so on accessible when executed.
来源:https://stackoverflow.com/questions/33933183/java-lang-classnotfoundexception-com-google-javascript-jscomp-sourcefile