Build a Java service using Eclipse

These instructions will install the Scribble and the Asteroids sample services using Eclipse.

Installing the Java sample service using Eclipse is a three-step process.

Steps

Create a project

The instructions below are based on Eclipse Neon; the steps may vary slightly if you are using a different version.

  1. Run Eclipse and select the File | New | Project menu option. This will launch a wizard.
  2. In the Select a wizard dialog, choose Java | Java Project and click Next.
  3. Enter a project name (ScribbleApp for Scribble, AsteroidsApp for Asteroids).
  4. Uncheck the Use default location checkbox.
  5. Click the Browse button and navigate to:
    [install_path]\SDK\Samples\Java
  6. Click Next.
  7. Click the Libraries tab.
  8. Click Add External Jars.
  9. Locate the external .jar files:
    [install_path]\SDK\Redistributable\Libs\Java
  10. Select all the jar files then click Open.
  11. Click Finish to create the project.

If the Setting Build Paths dialog appears, click No.


Configure the application plug-in

The plug-in file tells the PureWeb server where to find the service, as well as other information pertaining to the application.

The Java sample service comes with an application plug-in file already created, but when working with Eclipse you must manually edit a few placeholder values in that file.

  1. Open the source plug-in file:
    [install_path]\SDK\Samples\Java\conf\plugin.xml
  2. Save a copy at the following location and rename it:
    [install_path]\Server\conf\JavaSamples-plugin.xml
  3. Edit the copy as follows:
    1. Replace instances of the @plugin.bin.dir@ placeholder with the location of the redistributable libs, for example:
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java
    2. Replace instances of the @plugin.classpath@ placeholder with the list of .jar files, for example (these would all be in a single line, but are displayed on multiple lines below for easier readability):
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java\CSI.PureWeb.Client.jar;
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java\CSI.PureWeb.StateManager.jar;
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java\httpclient-4.0.1.jar;
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java\httpcore-4.0.1.jar;
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java\jdom.jar;
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java\log4j-1.2.15.jar;
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java\slf4j-api-1.5.10.jar;
      C:\CSI\PureWeb\SDK\Redistributable\Libs\Java\slf4j-log4j12-1.5.10.jar;
      C:\CSI\PureWeb\SDK\Samples\Java\build\classes\common;
      C:\CSI\PureWeb\SDK\Samples\Java\dist\CSI.PureWeb.Server.Samples.jar

Save and close the edited file.

Build the service

  1. In Eclipse, in the project you created in the first step, navigate to src/server and expand the content for the service that you want to build:
    pureweb.samples.[scribbleapp or asteroids]
  2. Double-click the service file (ScribbleApp.java or AsteroidsApp.java) to open it.
  3. Create a run configuration by selecting Run | Run Configurations.
  4. Right-click Java Application and select New.
  5. Click the Run button to run the service.

    If the server is already running, you do not need to restart it. Instead, simply reload the plug-ins (navigate to the server's Configuration page and click the Reload Plugins button). Otherwise if the server is not running, start it now and log in.

    You should now see your sample service in the Apps page of the PureWeb server, under Available Managed Applications.