I have no experience on coding in java using the vSphere API but maybe you can take a look at "vijava" (http://vijava.sourceforge.net/).
There also examples available at http://vijava.svn.sourceforge.net/viewvc/vijava/trunk/src/com/vmware/vim25/mo/samples/.