Building Ice Applications in Java

This page provides important information for Java developers.

On this page:

Prerequisites

In order to build applications with Ice in Java, you need:

  1. the Ice JAR files (ice.jar, icediscovery.jar, icegrid.jar, etc.)
    These JAR files are provided through Maven, as described below. Ice binary distributions for Debian and Ubuntu also include these JAR files.

  2. the slice2java compiler 
    slice2java is a command-line tool written in C++ and available on most platforms

    PlatformDistributionPackage with slice2java
    Debian and Ubuntuapt packageszeroc-ice-compilers
    RHEL, SLES, Amazon LinuxRPMsice-compilers
    macOShomebrewice
    WindowsMSIalways installed
    WindowsNuGetzeroc.ice.v100, zeroc.ice.v120, zeroc.ice.v140, zeroc.ice.v141,zeroc.ice.v142

       

  3. the Ice Builder for Gradle, if you are using Gradle.

Java and Java Compat Mappings

Ice provides two distinct Slice-to-Java mappings:

  • Java
    This is a new mapping that takes advantage of features in Java 8. We recommend you select this mapping for new Ice-based applications written in Java.
  • Java Compat
    This mapping is largely backward-compatible with prior Ice releases and does not depend on any Java 8-specific language or run-time features.

slice2java, the Slice-to-Java code generator, generates code for the Java mapping by default.

Maven Repository

You can fetch all Ice build artifacts from the Maven Central repository. ZeroC provides the following JAR files, all in group com.zeroc with version 3.7.3:

Starting with Ice 3.7.3 the JAR files for the Java mapping are modular JARs and provide Java modules when built with JDK 9 or higher. 

NameJava ModuleDescription
glacier2(na)Generated proxy and skeleton classes plus helper classes for connecting to the Glacier2 service
icecom.zeroc.iceIce core
iceboxcom.zeroc.iceboxThe IceBox server, and generated proxy and skeleton classes for connecting to IceBox
icebtcom.zeroc.icebtThe IceBT plug-in (only for Android)
icediscoverycom.zeroc.icediscoveryThe IceDiscovery plug-in
icegrid(na)Generated proxy and skeleton classes for connecting to the IceGrid service
icelocatordiscoverycom.zeroc.icelocatordiscoveryThe IceLocatorDiscovery plug-in
icepatch2com.zeroc.icepatch2Generated proxy and skeleton classes for connecting to the IcePatch2 service
icesslcom.zeroc.icesslThe IceSSL plug-in
icestorm(na)Generated proxy and skeleton classes for connecting to the IceStorm service

There is currently no module for glacier2 and icestorm because the com.zeroc.IceMX package is split in these JAR files, and Java modules do not allow split packages. There is currently no module for icegrid as it depends on glacier2.

NameDescription
glacier2-compatGenerated proxy and skeleton classes plus helper classes for connecting to the Glacier2 service
ice-compatIce core and IceSSL plug-in
icebox-compatThe IceBox server, and generated proxy and skeleton classes for connecting to IceBox
icebt-compatThe IceBT plug-in (only for Android)
icediscovery-compatThe IceDiscovery plug-in
icegrid-compatGenerated proxy and skeleton classes for connecting to the IceGrid service
icelocatordiscovery-compatThe IceLocatorDiscovery plug-in
icepatch2-compatGenerated proxy and skeleton classes for connecting to the IcePatch2 service
icestorm-compatGenerated proxy and skeleton classes for connecting to the IceStorm service



Bzip2

Ice for Java supports protocol compression using the BZip2 implementation included with Apache Commons Compress. Compression is automatically enabled if these classes are present in your CLASSPATH. The Maven package id for the JAR file is as follows:

groupIdversionartifactId
org.apache.commons1.14commons-compress

These classes are a pure Java implementation of the bzip2 algorithm and therefore add significant latency to Ice requests.

Using the Sample Programs

Sample programs are available at the ice-demos GitHub repository. You can browse this repository to see build and usage instructions for all supported programming languages. You can clone this repository with:

git clone -b 3.7 https://github.com/zeroc-ice/ice-demos.git
cd ice-demos