java - 运行 css-validator.jar 时出现 ClassNotFoundException 错误

标签 java w3c-validation

我正在尝试从 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/

相关文章:

java - java中默认构造函数和非参数构造函数的区别?

HTML Head 元素未在 w3.org 验证器上正确注册?

javascript - 如果 `name` 属性无效,如何识别表单?

css - 仅在 mozilla 中出现错误

html - 缺少 href 属性的 <a> 标签是否存在浏览器问题?

java - 简单的 string.equals() if 语句不工作 Java

java - 有没有办法获得SQS队列的平均服务时间?

java - getAction() 只给出 ACTION_DOWN

java - 为什么等于运算符适用于 128 之前的整数值?

html - "The language attribute on the script element is obsolete. You can safely omit it."?