What kind of errors do you mean?
If you mean syntax error, so there is a java compiler that checks the code against Java syntax.
If you mean design flaws or bad practices, have a look at Sonar...