I want to use sublime as development tool instead of eclipse, but although sublime enables to highlight the code, but how to detect the errors and compile the java code as eclipse does?
Sublime Text is a text editor, not an IDE. You'll need to compile it from command line using javac File.java. And it won't highlight errors for you.
If you want a simpler text editor how Java, consider jGrasp or NetBeans.