Installing and configuring: Eclipse for Java and Groovy

Eclipse is an open development platform developed by an open community. It includes extensible frameworks, tools and runtimes for building, deploying and managing software across the life cycle. The following sections of this article provide information about installing and configuring Eclipse for Java and Groovy:

Prerequisites

If you choose to develop with Eclipse, the following prerequisites are required:

Installation

To use this platform, follow these installation steps:

  1. If you do not already have Eclipse 3.2 (or later) installed go to http://www.eclipse.org to download and install it.
  2. The Project Zero plug-in also requires a version 1.5/5.0 (or later) JDK. The bin directory of the 1.5 JDK must be referenced in your PATH environment variable (appearing before any other Java installation). If you do not want to include the 1.5 JDK in your path, then you can start eclipse with a VM argument as shown in the following example:
    eclipse -vm <path_to_your_JDK>\bin\javaw
    
    Note: Use / for UNIX-based file systems.
  3. To verify that the correct version of Java is in your PATH, type java -version .
  4. Start Eclipse and click Window > Open Perspective > Java to change to the Java perspective.
  5. To configure the update sites in Eclipse do the following:
    1. Click Help > Software Updates > Find and Install ...
    2. Select Search for new features to install and click Next >.
    3. Click New Remote Site ....
    4. Enter a name like Project Zero Update Site and enter the following URL: http://www.projectzero.org/update/zero.eclipse.latest
    5. Click OK and then Finish.
  6. To install the Eclipse plug-in, do the following:
    1. Select the checkbox next to the name of the update site you added (Project Zero Update Site or the name you gave it) and click Next >. This will select all available features.
    2. Read and accept the license agreements and click Next >.
    3. Click Finish.
  7. Choose Install All and then click Yes when asked to restart Eclipse.

Creating and running an application

To create and then run a Project Zero application, use the following steps:

  1. Click File > New > Project ....
  2. Expand the Project Zero category folder near the bottom and click the Project Zero Application project type.
  3. Click Next >.
  4. Enter a name for your new application and click Finish to create it. Your new project is shown with a Project Zero icon beside it.
  5. To run your new application, right-click the project and click Run As > Project Zero Application. This launches the application. A message will be displayed in the console indicating that the application was started on port 8080.
  6. In a browser go to http://localhost:8080/ to see the default page of your application. It should look something like this:

    Default application page

  7. To see some details of the request, go to http://localhost:8080/zero/webtools/snoop.gt . It will give you a response like this:

    Request details page

  8. Stop your application.

Congratulations! You have created and run your first Project Zero application. Read on to find out how you can add additional libraries to enhance your application. You can also look at the Employee Demo or Suggest Demo for coding examples.

Resolving libraries

Under your project there are three containers, a JRE container and two Zero library containers. The Zero library containers are:

Zero Local Libraries
Adds all of the JAR and ZIP files from the /lib directory to your classpath .
Zero Resolved Libraries
Resolves libraries from configured repositories and adds them to your classpath . This container uses an ivy.xml file located in the config directory to resolve dependencies from repositories and adds the resolved JAR and ZIP files to your classpath .

You can add JAR files to the project classpath by copying them into the lib directory of the project, or by adding dependencies from repositories. When a project is first created, it has three dependencies: zero.core, zero.webtools, and zero.management.

A library can be pulled from a repository. The following steps show how this is done by editing the dependency configuration to add the zero.data library to the project:

  1. Double-click the config/ivy.xml file in your project to open the Zero Package Editor as shown below:

Zero Package Editor

2. Click the Add... button in the Dependencies section of the editor. The Dependency Selection dialog that displays allows you to select a dependency from the local repository which was installed with the Eclipse plug-in as shown below:

Dependency Selection dialog

3. If your local repository does not already contain the dependency that you need, as is the case here, click the Manage Repository button to find the dependency in a remote repository. This opens a new dialog like the following example:

Manage Repository dialog

4. Enter zero.data in the Module field and click Search to find the zero.data library. After finding it, select it and click Download to add the zero.data library to your local repository and click Close to exit the Manage Repository dialog.

3. Now, from the Dependency Selection dialog select zero:zero.data(1.0+) from the list and click OK. The dependency has been added to the list.

4. Click Ctrl-S or File > Save to save the modified package information.

5. To see the zero.data library added to your classpath as shown below, expand the Zero Resolved Libraries container under your project.

zero.data dependency added

6. If the library is not currently located in a repository, then you can add a library to the Zero Local Libraries container. To do this, drag and drop a JAR file into the /lib directory of your project. This triggers the Zero Local Libraries container to refresh and add the library to your classpath . You can expand the Zero Local Libraries container to see the JAR file.

Using Project Zero examples

If you installed all of the plug-ins (including the samples plug-in) from the Project Zero site, you can create example Zero projects in your workspace.

  1. Click File->New->Example....
  2. If you have multiple Example types, expand Zero Examples.
  3. Select Project Zero Example Projects and click Next >.
  4. Choose one or more examples to create as projects in your Workspace and click Finish.

See the Employee Demo and Suggest Demo documentation for more example code.

Enabling logging for the event core

To enable logging for the event core, use the following steps:

  1. Edit the logging.properties file in your installation directory under the config/logging.properties directory.
  2. To log all messages for the event engine, add the following line to the logging.properties file: zero.core.events.EventEngine.level=FINEST
  3. Start or restart Zero to pick up the logging changes.
  4. Right click the logs folder and click Refresh.

Exporting applications

To export your application, use the following steps:

  1. Right-click the project and click Export....
  2. Expand the Project Zero category.
  3. Select Project Zero Export Wizard and click Next.
  4. Click Browse... to select a directory and store the exported zip file.
  5. Check Include Source to include the source project.
  6. Click Finish to export the project.
Note: you must include source if you plan to import the project back into Eclipse.

Importing applications

To import a zero application that has the source included (see above), use the following steps:

  1. Click File > Import > General > Existing Projects into Workspace.
  2. Click Next.
  3. Select the Select Archive File radio button.
  4. Select Browse... to locate your exported zero zip file (for a project that is not already in your workspace) and click OK.
  5. Click Finish to import the checked project.

Version 1.0.15900.M6