The code for the sample REST API code must be
compiled with the IBM® Software
Development Kit (SDK) for Java™ 1.6.
Before you begin
Before you can build the sample REST API Java applications, you must install and configure
Apache ANT, a Java-based build tool. For information about how to
install and configure Apache ANT, see http://ant.apache.org/.
The
sample applications in the ES_INSTALL_ROOT/samples/rest directory
must run in a JRE Version 1.6 environment.
Procedure
To compile and run the sample REST API applications:
- From the command line, change to the ES_INSTALL_ROOT/samples/rest/admin directory. The default installation paths are:
- AIX®: /opt/IBM/es/samples/rest/admin
- Linux: /opt/IBM/es/samples/rest/admin
- Windows: C:\Program
Files\IBM\es\samples\rest\admin
- Run the ANT script by entering the following command. The directory includes a build.xml file that
ANT uses to compile the applications.
ant
You see the following message after the Java source code compiles: BUILD SUCCESSFUL
Total time: xx seconds
- Run the application by specifying the appropriate
command on a single line, where application is
the name of the application that you want to run:
- For the samples in the ES_INSTALL_ROOT/samples/rest/admin/com/ibm/es/admin/control/api/samples/jaxws directory
java -cp es.admin.rest.jar
com.ibm.es.admin.control.api.samples.jaxws.application
arguments_to_run_the_application
For
example:
java -cp es.admin.rest.jar
com.ibm.es.admin.control.api.samples.jaxws.GetAccess
- For the samples in the ES_INSTALL_ROOT/samples/rest/admin/com/ibm/es/admin/control/api/samples/commons directory
java -cp "%ES_INSTALL_ROOT%\lib\axis2\commons-fileupload-1.2.jar;
%ES_INSTALL_ROOT%\lib\axis2\commons-httpclient-3.1.jar;
%ES_INSTALL_ROOT%\lib\axis2\commons-logging-1.1.1.jar;
%ES_INSTALL_ROOT%\lib\axis2\commons-codec-1.3.jar;.\es.admin.rest.jar"
com.ibm.es.admin.control.api.samples.commons.application
arguments_to_run_the_application
For
example:
- AIX or Linux
java -cp "/opt/IBM/es/lib/axis2/commons-fileupload-1.2.jar:
/opt/IBM/es/lib/axis2/commons-httpclient-3.1.jar:
/opt/IBM/es/lib/axis2/commons-logging-1.1.1.jar:
/opt/IBM/es/lib/axis2/commons-codec-1.3.jar:./es.admin.rest.jar"
com.ibm.es.admin.control.api.samples.commons.GetAccess
- Windows
java -cp
"C:\Program Files\IBM\es\lib\axis2\commons-fileupload-1.2.jar;
C:\Program Files\IBM\es\lib\axis2\commons-httpclient-3.1.jar;
C:\Program Files\IBM\es\lib\axis2\commons-logging-1.1.1.jar;
C:\Program Files\IBM\es\lib\axis2\commons-codec-1.3.jar;
.\es.admin.rest.jar"
com.ibm.es.admin.control.api.samples.commons.GetAccess
On Windows, you can also run the applications by using
the resttest.bat sample batch file in the ES_INSTALL_ROOT/samples/rest/admin directory.
The sample batch file contains the command to run the com.ibm.es.admin.control.api.samples.jaxws.GetAccess
sample application. You can edit the batch file to run other sample
applications. To run samples in the ES_INSTALL_ROOT/samples/rest/admin/com/ibm/es/admin/control/api/samples/commons directory,
ensure that you specify the correct class path, as shown in the previous
command.