Getting started with vSphere API using Java

Recently I got introduced to VMware Infrastructure (aka vSphere) Java & I should say “VI Java is an incredible open source project  I have ever come across”. I am really humbled with the impact that Steve Jin’s contribution to the VMware community. I am sure this open source project is asset for thousands of VMware customers & partners. In the purview of the same, VI Java project inspired me to add “vSphere API” section in my blog. Under this section you can expect small utilities to manage your VMware environment which will be useful specially to most of the VMware administrators. Here we go with first post under “vSphere API” section. I am going to share how I got started with VI Java application development. i.e. Step by step tutorial on getting started with vSphere API using Java.

1. Goto VI java website Here. Click on “Download” tab on the top as shown in below screenshot.

VIJAVA_website_home_Page_1

2. Click on the latest release as shown below. 

Download_2Note: For future releases Zip file name would be different. Just you need to download latest one

3.  Extract the downloaded file at any location of your choice.Extract ZIP_file

4. You should see below jar files inside extracted Zip file.

EXtracted_2files_4

5. Now it is time to install Eclipse. Download eclipse from “https://www.eclipse.org/downloads” as shown below .Please make sure you have JDK/JRE 1.6 or higher

Eclipse download6. Create java project as shown below .

Create_Project_1Create_Project_2

Project_Create_3

Create_project_4

7. Configure the 2 jars files that were extracted above in step 5 as follows.

Create_project_5

Create_project_6

Create_project_7

Create_Project_8

8. Create first java program “HelloVM.java” as follows: Download source code from here:HelloVM.java. (Source code originally written by Steve Jin). Add this source code in java class created below.

Create_project_9

Create_Project_10

 9. You need to modify source code with vCenter IP, vCenter username & vCenter password as shown in below screenshot.

Create_project_1210. Run your first VI Java program as follows.

Create_project_13

Create_project_14

Great! Finally you got started with VI SDK and executed first VI SDK program. Stay tuned for more meaningful programs to manage your VMware environment.

7 thoughts on “Getting started with vSphere API using Java

  1. Hi Vikash,

    Nice article on getting started with vSphere API.
    Here VI Java API is used, which is a wrapper over the VMware’s original vSphere SDK API.

    Is VI-JAVA officially supported by VMware ? Or we have to use it our own risk ?

    Thanks,
    Aravind

    1. Hi Aravind,

      Thanks a lot for reading my post.

      Yes, It is wrapper around VMware’s original vSphere SDK. It is not officially supported by VMware. VI Java is now forked into another open source project i.e. YA VI JAVA (Yet Another VI JAVA). It is open source and some of the VMware engineers (like me) are active in community and using it.

      For YA VI Java, I have written couple of articles already. VI java was supporting till 5.5 and YA Vi java supports even 6.0 release as well.

      I would suggest to use YA Vi Java now: http://vthinkbeyondvm.com/great-news-yavi-java-fork-of-vi-java-open-source-project-supports-vmware-vsphere-6-0/

      http://vthinkbeyondvm.com/getting-started-with-yavi-java-opensource-java-sdk-for-vmware-vsphere-step-by-step-guide-for-beginners/

      So many companies use it and as per my experience, I have found no serious issues. This has been there since last 5-6 years.

Leave a Reply

Your email address will not be published.