src/main/java/com/wpollock/jaxbdemo/Main.java

package com.wpollock.jaxbdemo;

import javax.xml.bind.*;
import java.io.*;
import java.math.BigDecimal;

public class Main {
    public static void main ( String[] args ) throws JAXBException, FileNotFoundException {
        Long longId = 10L;
        User user = new User(longId, "Hymie", "HPiffl@wpollock.com");
        Product product = new Product("PO1", "HCC Coffee Mug",
                "https://images.hccfl.edu/mug.jpg", new BigDecimal(7.99), user);
        JAXBContext jaxbContext = JAXBContext.newInstance(Product.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        File file = new File("product.xml");
        marshaller.marshal(product, file);
        System.out.println("Generated \"" + file.getAbsolutePath() + "\".");
        marshaller.marshal(product, System.out);
    }
}