Closed jacklenox closed 3 years ago
how to reproduce:
$ wget -P css-validator-test/ http://www.w3.org/QA/Tools/css-validator/css-validator.jar
$ java -jar css-validator-test/css-validator.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: org/w3c/tools/resources/ProtocolException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.w3c.tools.resources.ProtocolException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
... 7 more
This follows the instructions from https://jigsaw.w3.org/css-validator/DOWNLOAD.html.en (at least as good as I understand)
hints to solve the problem: https://stackoverflow.com/a/15369527/4124767 (I adapted http: to https: and used a different version of htmlparser, see my comment there)
resulting in this installation script
#!/bin/bash
set -e
mkdir -p lib
curl -LO http://www.w3.org/QA/Tools/css-validator/css-validator.jar
echo "\
http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
https://repo1.maven.org/maven2/commons-lang/commons-lang/2.6/commons-lang-2.6.jar
https://repo1.maven.org/maven2/org/w3c/jigsaw/jigsaw/2.2.6/jigsaw-2.2.6.jar jigsaw.jar
https://repo1.maven.org/maven2/org/ccil/cowan/tagsoup/tagsoup/1.2/tagsoup-1.2.jar
https://repo1.maven.org/maven2/org/apache/velocity/velocity/1.7/velocity-1.7.jar
https://repo1.maven.org/maven2/xerces/xercesImpl/2.11.0/xercesImpl-2.11.0.jar xercesImpl.jar
https://repo1.maven.org/maven2/nu/validator/htmlparser/htmlparser/1.6/htmlparser-1.6.jar htmlparser-1.3.1.jar\
" | while read url shortname; do
if [ -z "$shortname" ]; then
shortname="${url##*/}"
fi
curl -L -o "lib/${shortname}" "${url}"
done
other links to same problem: https://lists.w3.org/Archives/Public/www-validator-css/2008Nov/0014.html https://stackoverflow.com/questions/24274483/classnotfoundexception-error-when-running-css-validator-jar?noredirect=1
The problem seems to be old ...
https://github.com/validator/validator/releases/download/jar/vnu.jar provides an alternative self-contained jar you can use for checking CSS stylesheets (along with HTML and SVG).
As documented at https://validator.github.io/validator/#standalone, you can run it like this:
java -cp ~/vnu.jar nu.validator.servlet.Main 8888
Then open http://0.0.0.0:8888 in a browser to see a form similar to https://validator.w3.org/nu/ that allows you to enter the URL of a CSS stylesheet (or HTML document, or SVG image) and have the results of checking that resource displayed in the browser.
You can also use the same jar for checking CSS stylesheets from the command line; in that case, as documented at https://validator.github.io/validator/#more-examples, you can invoke it with -jar
and the --css
option, like this:
java -jar ~/vnu.jar --css STYLESHEET.css
…or you can batch-check multiple CSS stylesheets by giving a directory name, like this:
java -jar ~/vnu.jar --css DIRECTORY_PATH
Just out of curiosity @sideshowbarker : Does v.nu (Nu Html Checker) contain css-validator? Is this from the same organisation?
For CSS checker, the Nu Html Checker uses the same backend code as the W3C CSS Validator (that is, the code in this github repo).
Could you try with the latest release? Also http://www.w3.org/QA/Tools/css-validator/css-validator.jar should now point to that latest release's jar. HTH
As it can't be reproduced with the latest release, let's close it.
Forgive my ignorance as I'm not very familiar with Java, but I'm getting this error when I try to run the
jar
with either Java 11 or 12:Any help much appreciated.