xjc example.xsd
public class ObjectFactory {
public Example createExample() {
return new Example();
}
}
@XmlRootElement
public class Example {
@XmlElement
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class Main {
public static void main(String[] args) throws JAXBException {
JAXBContext jaxbContext = JAXBContext.newInstance(Example.class);
Marshaller marshaller = jaxbContext.createMarshaller();
Example example = new Example();
example.setName("Hello JAXB!");
marshaller.marshal(example, new File("example.xml"));
}
}