Java eclipse error - Multiple Markers at this line - URL & SAXException cannot be resolved to a type
eclipse, java
Solution
Import the missing classes so that the unqualified types can be used in the program
import java.net.URL;
import org.xml.sax.SAXException;
Problem
I am writing a java code to validate XMLs against XSD file. Eclipse shows 2 error in following code. Multiple Markers at this line - URL cannot be resolved to a type SAXException cannot be resolved to a type ``` import javax.xml.XMLConstants; import javax.xml.transform.Source; import javax.xml.transform.stream.StreamSource; import javax.xml.validation.*; public class xml_validator_class { public static void main(String argv[]) { URL schemaFile = new URL("xsdfile.xsd"); Source xmlFile = new StreamSource(new File("xmlfile.xml")); SchemaFactory schemaFactory = SchemaFactory .newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); Schema schema = schemaFactory.newSchema(schemaFile); Validator validator = schema.newValidator(); try { validator.validate(xmlFile); System.out.println(xmlFile.getSystemId() + " is valid"); } catch (SAXException e) { System.out.println(xmlFile.getSystemId() + " is NOT valid"); System.out.println("Reason: " + e.getLocalizedMessage()); } } } ``` Kindly refer to this link for below program :