SAX (Simple API for XML) Implementation in JDK

This section provides a tutorial example on how to write a simple program to find out what are the implementation classes for the SAX interfaces in JDK. The key is to call the javax.xml.parsers.SAXParserFactory.newInstance() method.

What is SAX (Simple API for XML)? SAX is an Application Programming Interface (API) that allows the parser to fire events based on the XML structure while parsing an XML file. It allows application programs to process the contents of the XML by handling the events fired by the parser.

SAX has been implemented in Java in J2SDK 1.4.1_01, which is already installed on my system. So I am ready to play with XML files through SAX in Java.

The first task is to find out how JDK supports SAX. To do this, I wrote this simple program here,, to show what are the implementation classes for the SAX interfaces:

 * Copyright (c) All Rights Reserved.
import javax.xml.parsers.SAXParserFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.helpers.DefaultHandler;
import org.xml.sax.SAXException;
class SAXClassChecker {
   public static void main(String[] args) {
      try {
         File x = new File(args[0]);
         SAXParserFactory f = SAXParserFactory.newInstance();
         SAXParser p = f.newSAXParser();
         DefaultHandler h = new DefaultHandler();
      } catch (ParserConfigurationException e) {
      } catch (SAXException e) {
      } catch (IOException e) {

Run the program with JDK 1.8 or higher, you will get:

herong> java hello.xml

Note that:

If you are using JDK 1.4.1, the output should look like:

herong> \j2sdk1.4.1_01\bin\java SAXClassChecker hello.xml

Table of Contents

 About This JDK Tutorial Book

 JDK (Java Development Kit)

 Java Date-Time API

 Date, Time and Calendar Classes

 Date and Time Object and String Conversion

 Number Object and Numeric String Conversion

 Locales, Localization Methods and Resource Bundles

 Calling and Importing Classes Defined in Unnamed Packages

 HashSet, Vector, HashMap and Collection Classes

 Character Set Encoding Classes and Methods

 Character Set Encoding Maps

 Encoding Conversion Programs for Encoded Text Files

 Java Logging

 Socket Network Communication

 Datagram Network Communication

 DOM (Document Object Model) - API for XML Files

SAX (Simple API for XML)

SAX (Simple API for XML) Implementation in JDK

 SAX Content Handler Interface - SAX Based XML Browser

 DTD (Document Type Definition) - XML Validation

 XSD (XML Schema Definition) - XML Validation

 XSL (Extensible Stylesheet Language)

 Message Digest Algorithm Implementations in JDK

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Digital Signature Algorithm and Sample Program

 "keytool" Commands and "keystore" Files

 KeyStore and Certificate Classes

 Secret Key Generation and Management

 Cipher - Encryption and Decryption

 The SSL (Secure Socket Layer) Protocol

 SSL Socket Communication Testing Programs

 SSL Client Authentication

 HTTPS (Hypertext Transfer Protocol Secure)

 Outdated Tutorials


 Full Version in PDF/EPUB