public class Student {
private String name;
private int age;
}
<student>
<age>20</age>
</student>
xjc -d generated -p com.example.student student.xsd
JAXBContext jaxbContext = JAXBContext.newInstance(Student.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
Student student = (Student) unmarshaller.unmarshal(new File("student.xml"));
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.marshal(student, new File("student.xml"));