Skip Headers

# Using the JAXB Context

Previous

Next

You can create an instance of `JAXBContext` using the target package name you selected for your generated files (see "Understanding JAXB-Specific Generated Files") as the context path, as Example: Using the Context Path shows. This example assumes that you configure your application classpath to include your domain object class files.

The `JAXBContext` is thread-safe.

Using the Context Path

    JAXBContext jaxbContext = JAXBContext.newInstance("examples.ox.model");
    Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
    PurchaseOrder purchaseOrder = (PurchaseOrder)
        unmarshaller.unmarshal(new File("purchaseOrder.xml"));