Asking the same question, I see that there is a project called jcabi
that implements a very simple validation interface in Java.
http://w3c.jcabi.com
A very simple example based on their GIT readme:
import com.jcabi.w3c.HtmlValidator; assert ValidatorBuilder .html() .validate("<html>hello!</html>") .valid() ;
It seems to be checking the remote service (which seems redundant depending on what you are doing), although you can install your own local instance.
source share