Monday, October 23, 2006

Playing with JAXB

I am going through JAXB tutorial http://java.sun.com/webservices/docs/1.4/tutorial/doc/index.html and there are some loopholes that I had to jump over in order to make it work.

For example, here http://java.sun.com/webservices/docs/1.4/tutorial/doc/JAXBUsing2.html#wp87865 it gives not correct commands for compiling and running the primer.

The correct commands (provided that you've installed JWSDP in C:\Sun\jwsdp-2.0) are the following (you should be able to easily rewrite them with using environment variables instead of absolute paths):

Compiling:


Running:


Note the differences from tutorials' commands:
a) putting double quotes around %JAVA_HOME%\bin\javac because JDK is by default gets installed to c:\\Program Files\Java... which has white space in it
b) providing the classpath to the JAXB libraries (I don't know yet which ones of them are truly needed for this exactly exercise, I will learn it later)
c) in compiling I removed the primer\po\impl path - I don't know why it's there now (maybe for other examples?)
d) I copied the Main.java to the root forlder for this example from src folder

The output of this exercise is what was expected:



Very good! This exercise created Java classes from po.xsd and then it read the po.xml to these classes.

So far so good. Let's see what's next in JAXB goodies chest.

No comments: