Java – Writing XML using JAXB

package com.pwn.xml;

import javax.xml.bind.JAXB;

public class XMLWriter {

	public static void main(String[] args) {
		User user = new User();
		try {
					new File("C://install//userDetail.xml"));
		} catch (Exception e) {
					"Exception occurred while writing in XML!");
		} finally {
			System.out.println("XML created");



class User {
	private long userID;
	private String name;

	public long getUserID() {
		return userID;

	public void setUserID(long userID) {
		this.userID = userID;

	public String getName() {
		return name;

	public void setName(String name) { = name;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s