The Slice2Java Eclipse plug-in manages all aspects of code generation, including automatically recompiling Slice files that have changed, removing obsolete generated classes, and tracking dependencies.
On this page:
Configuring the Slice2Java Eclipse Plug-in
Choose Window -> Preferences, select Slice2Java, and review the default setting for the location of your Ice installation. The property pane will display an error message if the plug-in considers the specified location to be invalid. If necessary, click Browse... to pick the top-level directory of your Ice installation and apply your changes.
The Slice2Java plug-in automatically configures a workspace classpath variable named ICE_HOME that refers to the Ice installation directory you specified in the Preferences dialog. This variable is primarily intended for use in Android projects.
Activating the Slice2Java Plug-in for a Project
You can activate the Slice2Java plug-in for your project by right-clicking on the project, choosing Slice2Java and clicking Add Slice2Java builder. The plug-in immediately makes several additions to your project:
- Creates a slice subdirectory to contain your Slice files. The plug-in automatically compiles any Slice file that you add to this directory.
- Creates a generated subdirectory to hold the Java source files that the slice2java translator generates from your Slice files.
- Adds a library reference to the Ice run time JAR file (Ice.jar) for non-Android projects. The plug-in assumes that the JAR file resides in the lib subdirectory of your Ice installation.
Configuring Slice2Java Project Settings
To configure the project-specific Slice2Java settings, select Properties from the Project menu or right-click on the name of your project and choose Properties. Click on Slice2Java Properties to view the plug-in's configuration settings, which are presented in three tabs: Source, Options, and Libraries.
Settings in the Source Tab
This tab configures the directories of your Slice files and generated code. The plug-in includes the slice subdirectory by default, but you can remove this directory and add other directories if necessary. The plug-in only compiles Slice files that are located in the configured subdirectories.
For the generated code, the plug-in uses the default name generated for the subdirectory. If you want to store your generated code in a different directory, you must first create the directory and then click Browse to select it. Be aware that the plug-in requires exclusive use of the subdirectory you designate, therefore you must not place other project resources in it.
Settings in the Options Tab
This tab is where you configure additional plug-in settings. You can enter a list of include directories corresponding to the compiler's -I option. You can also specify preprocessor macros and metadata definitions in the fields provided. Finally, checkboxes offer additional control over certain features of the plug-in and the Slice compiler. When enabled, the checkboxes have the following semantics:
- Enable stream generates code to support the dynamic streaming API
- Enable tie generates TIE classes
- Enable ice instructs the compiler to accept Slice symbols that use the ice prefix
- Include Ice Slice Files adds an implicit include (-I) option that refers to the slice subdirectory of your Ice installation
- Enable console causes the plug-in to emit diagnostic information about its activities to Eclipse's console
- Enable underscore determines whether underscores are permitted in Slice identifiers (this feature is only supported in Ice 3.4.1 or later)
Settings in the Libraries Tab
This tab allows you to configure the Ice JAR files with which your application is built. The check box labeled Add JAR file references to project determines whether the plug-in adds an Ice Library entry to your project's build path. This check box is enabled by default, but you may want to disable it if the Ice JAR files are already present in your build path.
During a build, the Ice Library entry is substituted with the JAR files that you have added to the list.
Note that Android projects cannot use the Ice Library indirect reference, therefore the Libraries tab is disabled.
Configuration Notes for Android Projects
You must manually add Ice.jar to the build path of Android projects. Follow the instructions below to configure your project:
- Select Java Build Path in the project's properties
- Click on the Libraries tab
- Click Add Variable...
- Select ICE_HOME and click Extend...
- Open the lib subdirectory and select Ice.jar
- Click OK to save your changes
| ICE_HOME is a workspace classpath variable that is defined by the Slice2Java plug-in and always refers to the Ice installation directory that you specified earlier. |
The plug-in always rebuilds a project after its properties have been changed, but it may be necessary to refresh the project after changing a project's build path. To refresh a project, select it and press F5, or right-click on the project and choose Refresh.

