VMware logo

Readme for Java Samples


This document includes these topics:

This document includes summary information only. See the Developer’s Setup Guide (Chapter 2, “Setting Up for Java Development“) for complete information.

Note:   Information in this document may not be current. For up-to-date information, check these VMware Web sites:
Beta or Pre-release Products VMware Beta Community
Released SDK ProductsVMware vSphere Web Services SDK

Building the Samples

The vSphere Web Services SDK includes several scripts (batch files for Windows environments; shell scripts for Linux environments) to facilitate building and running the samples. These batch files require setting several environment variables. If your development workstation is setup using Java JDK 1.5 (or later) and Axis 1.4, you can use the sample applications, as is, without re-generating client-side proxy code and re-compiling.To run any samples, simply use the run.bat (or run.sh).

To use the build script (build.bat for Windows; build.sh for Linux)

  1. Set the environment variables as shown in the table.

    Environment
    variable
    Description and usage notes Example setting
    AXISHOMEComplete path to the Apache Axis installation top-level directory. Must be set prior to using build.bat, build.sh, run.bat, and run.sh scripts.C:\apache\axis1.4
    JAVAHOMEPath to the binary directory for the Java JDK. C:\jdk1.5_0_08
    WBEMHOMEPath to the WBEM (Web Based Enterprise Management) Java archive. SDK\samples\Axis\java

  2. Open the Windows command prompt (or Linux shell).
  3. Navigate to the SDK\samples\Axis\java sub-directory.
  4. Enter build at the command prompt. To rebuild without re-generating stubs, pass -w to the build script, on the command line. Here are some examples:
    c:>build.bat   [Windows]
    % build.sh   [Linux]
    build -w   [Windows]
    build.sh -w   [Linux]

See the Developer’s Setup Guide (Chapter 2, “Setting Up for Java Development“) for complete information.

Running the Samples

The SDK includes scripts (run.bat for Windows; run.sh for Linux) to simplify running the Java samples.

To use the run script (run.bat for Windows; run.sh for Linux)

  1. Set the environment variables listed in the table:

    Environment
    variable
    Description and usage notes Example setting
    AXISHOMEComplete path to the Apache Axis installation top-level directory. Must be set prior to using build.bat, build.sh, run.bat, and run.sh scripts.C:\apache\axis1.4
    JAVAHOMEPath to the binary root directory for the Java JDK or the JRE. C:\jdk1.5_0_08
    VMKEYSTOREPath to Java keystore. The VMKEYSTORE environment variable is used by the run.bat and run.sh scripts. It is required, even if you plan to use the ––ignorecert argument when running Java applications (using the run script). VMKEYSTORE=C:\VMware-Certs\vmware.keystore [Windows]

    VMKEYSTORE=/root/vmware-certs/vmware.keystore [Linux]
    WBEMHOMEPath to the WBEM (Web Based Enterprise Management) Java archive. SDK\samples\Axis\java

  2. Open the Windows command prompt (or Linux shell).
  3. Navigate to the SDK\samples\Axis\java sub-directory.
  4. Enter run at the command prompt, passing the name of the Java sample and the required command-line arguments. For example:
    c:> run.bat com.vmware.vimsample.SampleName <webserviceurl> <username> <password> <Other application-specific parameters> ...

See the Developer’s Setup Guide (Chapter 2, “Setting Up for Java Development“) for complete information.

Sample Applications

The SDK package includes generated Javadoc for the sample applications and helper classes, in this path:

%SDKHOME%\SDK\doc\samples\javadoc

If the relative link above does not work, manually navigate to the sub-directory.

The Java sample applications all use the helper classes available in the com.vmware.apputils package. The AppUtils class defines several options that are used by all the samples.

Command-line Options Common to All the Java Samples in the vSphere Web Services SDK Package


Option Description Usage note or example
--urlRequired. Complete URL for the vSphere API Web service for the connection. --url http://myesxserverorvcserver/sdk
--userNameRequired. User account with privileges to connect to the host.--userName sdkuser
--passwordRequired. Password for the user account.--password <password>
--serverFully-qualified name of the VMware vSphere server (ESX, ESXi, vCenter, for example) to connect to, such as myserver.mycompany.com.--server myserver.mycompany.com
--portNumberServer port for the vSphere API Web service. Default is 443 (for HTTPS).--portNumber 8080
--protocolProtocol for the server connection (HTTP, HTTPS; HTTPS is the default).--protocol http
--servicePathService path for the vSphere API Web service, such as /sdk, /sdk/webService--servicePath /sdk
--sessionFileFile containing a previously saved session cookie, for re-establishing connection to the server.--sessionFile mysession
--ignorecertAvoid the SSL server-certificate validation process.--ignorecert ignorecert
--configLocation of an optional configuration file that contains the required parameters. --config myconfigfile
--helpDisplay list of command-line options for the application.--help

In addition to the common options listed in the table, specific Java samples may implement specific options, relevant for the application.

To display help text for any application, simply run the application without any parameters. Parameters for sample applications are also available in the Javadoc, and in the listing in the table.

VMware Resources

Copyright © 2009 VMware, Inc. All rights not expressly granted herein are reserved.

Last updated: 8-Dec-2008 12:30 pm  |  VMware vSphere Web Services SDK