Sample programs are available for download for C++, Java, Android, C#, Visual Basic, Ruby, Python and PHP. Below you will find instructions for building and running these programs. The instructions assume that you have configured your platform according to the instructions in the release notes.

On this page:

Building the Demos

This section describes how to build the demos included in the Ice demo distribution.

The demo archive contains sample programs for each language mapping that Ice supports. Not all demos will build against all Ice distributions. Distributions for specific platform/tool combinations may not support every Ice language mapping.

Depending on the language mapping, various build tools are required for building the demos. The C++, C#, and PHP demos use makefiles, the Java demos use the Apache Foundation's ant build tool, and the Android demos require Eclipse and the Slice2Java plug-in.

The Ruby and Python demos do not need to be built.

Demo Prerequisites

The makefiles for C++, C#, and PHP require GNU make 3.80 or later. If your system does not come with GNU make, you can find information on how to acquire it at the following link:

http://www.gnu.org/software/make/

The Ice for Java demos require Ant 1.7.0, but we recommend using the most recent release available. Ant can be obtained at:

http://ant.apache.org/bindownload.cgi

The Ice for Android demos require Eclipse and the Slice2Java plug-in. The demos were tested with Eclipse Helios (3.6).

http://www.zeroc.com/eclipse.html

Demo Build Instructions

To build the demos you need to:

Demo Build Instructions for Android

Several sample Android projects are provided in the demoj/android subdirectory. You must use Eclipse and the Slice2Java plug-in to build these projects.

In Eclipse, you can open a sample project by choosing File->Import...; in the "General" group, select "Existing Project into Workspace", then open one of the subdirectories of demoj/android.

The sample projects are configured to locate the Ice run time JAR file (Ice.jar) via the ICE_JAR_HOME classpath variable.

If you installed Ice.jar in a different location, you will need to add it as an external JAR file in each sample project:

  1. Open the project's properties and select Java Build Path
  2. Click on the Libraries tab
  3. Click Add External JARs... and navigate to Ice.jar
  4. Click OK to save your settings

Running the Ice Demos

Most demos consist of a single server and client. The instructions to run a demo depend on the programming language. Instructions for each language are included below. Some demo directories contain a README file if additional steps are necessary.

Running the C++ demos

C++ demos are provided in the demo directory.

To run a demo, open a terminal window, change to the desired demo directory, and enter the following command to run the server:

{zcode}
$ ./server
{zcode}

To run the client, open another terminal window, change to the same demo directory, and run:

{zcode}
$ ./client
{zcode}

Running the Java demos

Java demos are provided in the demoj directory.

After a successful build, the compiled classes are stored in a subdirectory named classes in each demo directory. You need to add this subdirectory to your CLASSPATH. For example, with a bash shell:

{zcode}
$ export CLASSPATH=classes:$CLASSPATH
{zcode}

Your CLASSPATH should also include Ice.jarFreeze.jar, and other service-specific JAR files, as per the Release Notes instructions.

To run a demo, open a terminal window, change to the desired demo directory, and enter the following command to run the server:

{zcode}
$ java Server
{zcode}

To run the client, open another terminal window, change to the same demo directory, and run:

{zcode}
$ java Client
{zcode}

Running the Android demos

After successfully building an Android project, deploy it onto a suitable emulator or device and review the README file in the project subdirectory for further instructions.

Running the C# demos

C# demos are provided in the democs directory.

The C# demos are only supported on SuSE Enterprise Linux Server and Ubuntu but may work on other platforms. Note however that the Ice for .NET run time is included only in the binary distributions for SuSE Enterprise Linux Server and Ubuntu.

To run a demo, open a terminal window, change to the desired demo directory, and enter the following command to run the server:

{zcode}
$ mono server.exe
{zcode}

To run the client, open another terminal window, change to the same demo directory, and run:

{zcode}
$ mono client.exe
{zcode}

Running the Python demos

Python demos are provided in the demopy directory.

To run a demo, open a terminal window, change to the desired demo directory, and enter the following command to run the server:

{zcode}
$ python Server.py
{zcode}

To run the client, open another terminal window, change to the same demo directory, and run:

{zcode}
$ python Client.py
{zcode}

Running the Ruby demos

Ruby demos are provided in the demorb directory.

Ice provides only client demos in Ruby since Ice for Ruby does not support server-side activities. In order to run a sample client, you must first start its corresponding server from another Ice language mapping. For example, start the C++ hello server:

{zcode}
$ cd $HOME/testing/Ice-3.5.1-demos/demo/Ice/hello
$ ./server
{zcode}

To run the client, open another terminal window, change to the corresponding demo directory, and run:

{zcode}
$ cd $HOME/testing/Ice-3.5.1-demos/demorb/Ice/hello
$ ruby Client.rb
{zcode}

Running the PHP demos

PHP demos are provided in the demophp directory.

The Ice extension for PHP is provided as a dynamically-loadable shared library in Linux RPM distributions. On all other Unix platforms, you will need to build PHP and the Ice extension from source code. Please refer to the php/INSTALL file included in the Ice source distribution for more information.

The examples in demophp/Ice/hello and demophp/Glacier2/hello demonstrate the use of the Ice extension for PHP in a dynamic Web page, whereas the example in demophp/Ice/value requires PHP's command line interpreter. All examples require that an Ice server be available; a matching server from any of the other language mappings can be used. A README file is provided in each of the example directories.

Note that you may need to modify the php.ini files in each demo directory to match your PHP installation and ensure that the Ice extension is loaded properly.