fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.math.*;
  6. import java.io.*;
  7. import javax.xml.bind.*;
  8. import javax.xml.bind.annotation.*;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. final JAXBContext context = JAXBContext.newInstance(Message.class);
  16.  
  17. final Marshaller marshaller = context.createMarshaller();
  18. marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
  19.  
  20. marshaller.marshal(new Message(), System.out);
  21. }
  22. }
  23.  
  24. @XmlRootElement(name = "Message", namespace = "http://e...content-available-to-author-only...e.com/schema/message")
  25. class Message {
  26. @XmlElement(name = "Version")
  27. public int getVersion() { return 1; }
  28. }
  29.  
Success #stdin #stdout 0.13s 2315264KB
stdin
Standard input is empty
stdout
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:Message xmlns:ns2="http://e...content-available-to-author-only...e.com/schema/message">
    <Version>1</Version>
</ns2:Message>