Command-line interface
The IBM® WebSphere® sMash command-line interface (CLI) provides the basic support for developing and running WebSphere sMash applications. Alternatives for developing applications include App Builder and, for Java™-intensive development, an Eclipse plug-in for Java and Groovy.
Prerequisites
The following prerequisites are required to use the command line tools:
- Windows®, Linux®, or Mac operating system
- Java SE Development Kit (JDK) 5.0 or 6.0
IBM employees should download the Java SDK from the IBM internal site.
Installation
- Download the
zero-<version>.zip. Accept the license agreement, then clickzero-<version>.zipto download. - Unzip
zero-<version>.zipinto any directory. The root directory after unzipping is called zero. Refer to this directory as<zerohome>.WebSphere sMash does not support double-byte character sets on the installation path.
- Configure the Java command by setting the environment variable
JAVA_HOME.
The zero scripts determine the Java command to use by first using the environment variable JAVA_HOME. JAVA_HOME should be set to the directory where the JDK is installed. The scripts append bin/java to JAVA_HOME and verify whether the file exists. If JAVA_HOME is not set, or if ${JAVA_HOME}/bin/java does not exist, then the script uses the Java command found using the configured path. The recommendation is to set JAVA_HOME. - If a proxy is required to access external sites, then modify the zero scripts for the proxy. For example, set the proxyHost and proxyPort. The zero commands will download required modules, so ensure the proxy is configured.
- (Optional) Add
<zerohome>to the PATH environment variable. - If you plan to use the App Builder, you can proceed to the App Builder Quick-start tutorial section of this guide. If you would like to try out the command line, proceed to Getting started, below.
Getting started
The instructions below show you how to create a simple application using the command line interface.
- Open a command prompt.
- Type the following:
-
zero create demo - This creates a new WebSphere sMash application, which is created in a new subdirectory named demo.
-
- Change directory into
demo. - Type
zero startto start the application. Log messages are printed showing that the HTTP adapter has started, as shown in the following screen capture:
- Open a browser and type
http://localhost:8080/. A default page is shown with status and links for additional information, as shown in the following screen capture:
-
The application you just created is using port 8080 for communication. All WebSphere sMash applications use port 8080 by default, but only one application can use it at a time. Stop this application using
zero stopto free the port for use by another WebSphere sMash application.
Adding PHP support (Optional)
If you want to add PHP support for your application, complete the following steps:
- Stop the application.
zero stop - Add the PHP dependency to the application. Within your application's directory, edit
config/ivy.xml. Add the entry<dependency name="zero.php" org="zero" rev="[1.0.0.0, 2.0.0.0["/>to thedependencieselement. - Find the new dependency and associate it with your application. This step is called resolving the dependency.
zero resolve - Add PHP scripts to the application's
publicdirectory. - Optionally, modify the settings in the PHP configuration file
config/php.ini. - Start the application.
- From the browser, type
"http://localhost:8080/<name of script>.php"to run the script.
To run PHP on a Windows operating system, ensure you have the Microsoft Visual C++ 2005 Redistributable Package (x86) installed.