Getting Started
This guide walks you from a brand-new Maven project to a working “Hello, vSphere” program.
Prerequisites
- JDK 11 or later
- Maven or Gradle
- Access to a vCenter or
vcsim(a vSphere API simulator from the govmomi project)
Add the dependency
Maven:
<dependency>
<groupId>com.toastcoders</groupId>
<artifactId>yavijava</artifactId>
<version>9.0.0</version>
</dependency>
Gradle:
implementation "com.toastcoders:yavijava:9.0.0"
Hello, vSphere
import com.vmware.vim25.mo.ServiceInstance;
import java.net.URL;
public class Hello {
public static void main(String[] args) throws Exception {
ServiceInstance si = new ServiceInstance(
new URL("https://vc.example.com/sdk"),
"administrator@vsphere.local",
"password",
true); // ignore self-signed certs in dev
System.out.println(si.getAboutInfo().getFullName());
si.getServerConnection().logout();
}
}
Replace the URL and credentials. Run it. You should see the vCenter version string.
Where to go next
- Sample programs
- Javadoc
- yavijava-sso — SSO login for vCenter, if you need it