4
votes

Can I set a jaxb provider programmatically in a JAVA SE application (not web application)?

I'm looking for other approach instead jaxb.properties file with javax.xml.bind.context.factory=org.eclipse.persistence.jaxb.JAXBContextFactory

1

1 Answers

6
votes

You could do the following:

import javax.xml.bind.*;
import org.eclipse.persistence.jaxb.JAXBContextFactory;

public class Demo {

    public static void main(String[] args) throws Exception {
        JAXBContext jc = JAXBContextFactory.createContext(new Class[] {Metadata.class}, null);

}