Install MOXy as a JAXB Provider Programmatically

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

I am looking for a different approach instead of the jaxb.properties file with javax.xml.bind.context.factory = org.eclipse.persistence.jaxb.JAXBContextFactory

+4
source share
1 answer

You can 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);

}
+6
source