我正在尝试从 w3 实现 css-validator,但每次尝试都失败,并引发错误消息。
这是我遇到的错误:
"Directory Redacted"\framework-web>java -jar "Directory Redacted"\Downloads\
css-validator.jar http://www.w3.org
Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/tools/resourc
es/ProtocolException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.w3c.tools.resources.ProtocolExc
eption
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 6 more
此错误消息究竟表示什么,我该如何解决?
最佳答案
应用程序似乎正在使用“ProtocolException”类:
http://jigsaw.w3.org/Doc/Programmer/api/org/w3c/tools/resources/ProtocolException.html
您的类路径中可能缺少它。我会看看您是否可以将包含的 jar 添加到您的 ant 类路径中。
此外,如果您在这里查看 Sinan 的回答: How can I validate CSS on internal web pages?
是否有随应用程序一起提供的 ant 构建文件?如果是这样,它可能就像针对该 build.xml 运行 ant 以获取依赖项一样简单,然后通过命令行运行 java -jar。
关于java - 运行 css-validator.jar 时出现 ClassNotFoundException 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24274483/