CelinHC
CelinHC

Reputation: 1984

Set MOXy as JAXB provider programmatically

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

Upvotes: 4

Views: 1403

Answers (1)

bdoughan
bdoughan

Reputation: 148977

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

}

Upvotes: 6

Related Questions