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.
Update: VI Java project has now YAVI JAVA, please start using this guide to get started with YAVI JAVA instead of below steps. Since it supports vSphere 5.5 as well as vSphere 6.0 SDK, it is recommended to use YAVI JAVA. All the automation written using VI JAVA will work fine on YAVI JAVA.
1. Goto VI java website Here. Click on “Download” tab on the top as shown in below screenshot.
2. Click on the latest release as shown below.
Note: 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.
4. You should see below jar files inside extracted Zip file.
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
6. Create java project as shown below .
7. Configure the 2 jars files that were extracted above in step 5 as follows.
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.
9. You need to modify source code with vCenter IP, vCenter username & vCenter password as shown in below screenshot.
10. Run your first VI Java program as follows.
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.
Vikas Shitole is a Staff engineer 2 at VMware (by Broadcom) India R&D. He currently contributes to core VMware products such as vSphere, VMware Private AI foundation and partly VCF . He is an AI and Kubernetes enthusiast. He is passionate about helping VMware customers & enjoys exploring automation opportunities around core VMware technologies. He has been a vExpert since last 11 years (2014-24) in row for his significant contributions to the VMware communities. He is author of 2 VMware flings & holds multiple technology certifications. He is one of the lead contributors to VMware API Sample Exchange with more than 35000+ downloads for his API scripts. He has been speaker at International conferences such as VMworld Europe, USA, Singapore & was designated VMworld 2018 blogger as well. He was the lead technical reviewer of the two books “vSphere design” and “VMware virtual SAN essentials” by packt publishing.
In addition, he is passionate cricketer, enjoys bicycle riding, learning about fitness/nutrition and one day aspire to be an Ironman 70.3
Thanks a lot for your comment. Yes, I will be writing post on useful vSphere operations those will demonstrate how vSphere APIs can be explored using VI Java.
Please refer new tutorial on vSphere APIs:: https://vthinkbeyondvm.com/tutorial-vsphere-api-using-java-how-to-get-datastore-summary-for-all-data-stores-connected-to-a-esxi-host/
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
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: https://vthinkbeyondvm.com/great-news-yavi-java-fork-of-vi-java-open-source-project-supports-vmware-vsphere-6-0/
https://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.
Hi Vikash,
Nice article.
So far We are using vijava-5.0.0.jar for vsphere 6.5. Now we want to upgrade 6.7 version.
Will it work for 6.7 version ?. If not what needs to be upgrade.
You can upgrade to YAVI java, which supports up to 6.0 : https://vthinkbeyondvm.com/getting-started-with-yavi-java-opensource-java-sdk-for-vmware-vsphere-step-by-step-guide-for-beginners/
This will work mostly on 6.7 vSphere env also but any feature new in 6.7 or 6.5 can not be used using this since it supports till 6.0.