Steve Jin, Creator of VI Java API
On the download page, select the latest release and click the download link as follows:
Choose the binary vijava2b120090221.zip
(Note: the name can be different for future releases. Just pick up latest
one) and start to download it. Optionally, you can download the package
with source code -- vijava*src.jar.
If you already use Eclipse, it’s most likely your workspace has projects already. That is totally fine. Note: JDK/JRE1.6 or higher is required. Please upgrade if not yet. 1.5 can be supported but need a little tweak.
Then you will see the project get created:
a) Right click the project name and select the “Properties” (normally the last one in the context menu).
b) You will see a dialog box titled as “Properties for MyFirstVIJavaAPIProj.” Select “Java Build Path” from the left side, and “Libraries” tab on the right side.
c) Click “Add External JARs…” and select the two jars you just unzipped as follows:
a) Create a new Java class by Right Click New Class.
b) Copy the sample code and paste into the HelloVM.java. Save it. http://vijava.svn.sourceforge.net/viewvc/vijava/trunk/src/com/vmware/vim25/mo/samples/HelloVM.java
a) Right click “HelloVM.java” and choose Run As Java Application. You will see error from the console. Oops… What is wrong?
b) Double click the HelloVM.java file and locate the following line:
ServiceInstance si = new ServiceInstance(new URL(https://8.8.8.8/sdk"), "root", "password", true);
Note: You must change it to your own environment. And don’t forget the SDK in your url string. The https works by default, and http works as well if you have changed server side configuration.
c) After you click the Run button, you
will see print out from the Console View like the following:
Congratulations you got your first VI SDK program running in Java! Additional tutorial can be found at VMware community here by Pierre Lainé.
1. Subscribe to the blog, and follow Steve at Twitter. The blog site has many in-depth introductions and discussions about the API. Optionally, you can buy the book VMware VI and vSphere SDK (Disclosure: it's written by Steve) for the most complete introduction of vSphere API and VI Java.
2. Try more samples shipped with VI Java API. Check them out from http://vijava.sf.net
3. Participate in the community forum. You can find the link to forum from project home.
4. Let me know how you like it and how we can make it better for you. You can leave message in the forum or feature request.