How to Get ESX Version from vCenter?

There is a recent question in vSphere(VI) Java API forum about this. On its face, it’s very easy because most people know how to get hold of the version as follows: 

String version = si.getAboutInfo().getVersion();

The si in the above code is the variable of ServiceInstance object. If you have never used the API yet, please try this Getting Started Tutorial which shows how to get your first program running from scratch in 5 minutes

Lost VMs or Containers? Too Many Consoles? Too Slow GUI? Time to learn how to "Google" and manage your VMware and clouds in a fast and secure HTML5 App.

If you are connecting to a vCenter server and try to get the version of a HostSystem the vCenter manages, it’s not so obvious. But it’s definitely doable. Here is the solution assuming you already get hold of the HostSystem object as host variable here: 

String version = host.getConfig().getProduct().getVersion();

Here you know why. First, the aboutInfo is now called product although they are of the same type. Second, it’s hidden within the config property. 

Before taking the code away, I would like to share with you an important tip for better performance. You should consider the following code: 

String version = (String) host.getPropertyByPath(“config.product.version”);


AboutInfo ai = ((AboutInfo) host.getPropertyByPath(“config.product”);
String version = ai.getVersion();


Because config object could be huge and it takes time for the vCenter to grab the data and serialize it to XML, and for VI Java API to de-serialize XML back to data object. You can expect getConfig() call take about one second to finish. Most of that time is on vCenter side for grabbing data. So to avoid this, you can just fetch the sub-properties with much faster speed. 

This tip works as well if you connect to ESX directly.

This entry was posted in vSphere API and tagged , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. Posted August 16, 2010 at 12:12 am | Permalink

    Nice tip Steve. How can I search your blog posts for similar tips on using the SDK? because I don’t see tags on the posts. If you’d tagged this one like sdk-tips or something then it would’ve been great help. Anyways, you and your work rocks! keep us entertained with it :)

  2. Posted August 17, 2010 at 3:30 am | Permalink

    Sorry, I see the tags now, dunno how I missed them earlier on.

  3. Posted August 17, 2010 at 3:05 pm | Permalink

    Thanks Monis,

    Need your comments as well. Keep them coming! :-)


  4. nikhil
    Posted July 3, 2012 at 1:07 pm | Permalink

    hi steve…
    i m doing project on managing esxi server and i need different methods defined in vi java api…
    so i will be thankful if you provide me possible methods with its proper syntax

    tanks a lot in advance

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.