3.5 Running GreenPages from Eclipse
Prev | 3. Installing and exploring GreenPages | Next

## 3.5 Running GreenPages from Eclipse

Using Eclipse and the Web Server tools, it is possible to run applications directly from the IDE. As changes are made to the application in the IDE, they can be automatically applied to the running application allowing for rapid feedback of changes in function.

### Importing the GreenPages projects into Eclipse

Before you can start the GreenPages application from Eclipse, you must import the projects. To import the projects into Eclipse:

1. Open the Import Wizard using File → Import.

2. From the Import Wizard select General → Existing Projects into Workspace and click Next:

3. Click Browse… and select `$GREENPAGES_HOME/solution` as the root directory.

4. In the Import Projects window, select all the projects and click Finish:

5. Validate that the imported projects appear in Package Explorer:

   There may be compilation errors at this stage.

### Configuring Web Server target runtime

Projects for Web Server are associated with a Virgo Web Server runtime environment in Eclipse. This is to allow launching and testing from within Eclipse, and also to allow classpath construction in Eclipse to mirror the dynamic classpath in the Web Server runtime.

Compilation errors in the previous step will be resolved here.

To configure a Web Server runtime environment:

1. Open Window → Show View → Other….

2. In the Show View dialog choose Server → Servers to make the servers view visible:

3. Right-click in the Servers (which may not be empty) view and select New → Server.

4. In the New Server dialog, choose EclipseRT → Virgo Web Server and click Next.

5. Click Browse and select the `$VWS_HOME` directory. Ensure that a JRE is selected supporting Java 1.6 or above. Click Finish to complete creation of the server:

6. Select all projects (except Servers) in Package Explorer. Right-click on the projects and choose Close Project and then Open Project.

It is possible that there remain spurious build errors from Eclipse (see the Problems view), in which case a project clean build may clear the problems. Select Project → Clean… from the main menu, and choose to Clean all projects. It may be necessary to repeat this on a few projects. (This process is sometimes known as the “Eclipse dance”.)

Despite the dance steps outlined, there will remain some Warnings like this:

It is safe to ignore these.

### Running GreenPages from within Eclipse

Now that GreenPages is successfully imported into Eclipse, you can run the project directly from within the IDE.

If you previously deployed the GreenPages PAR to Web Server by copying the PAR file to the `pickup` directory, be sure you now remove it so that it does not conflict with the deployment of the Eclipse project. On Unix:

    prompt$ cd $VWS_HOME/pickup
    prompt$ rm greenpages-solution-2.1.0.RELEASE.par

On Windows:

    prompt> cd %VWS_HOME%\pickup
    prompt> del greenpages-solution-2.1.0.RELEASE.par

Also, to prevent conflicts with the server configured in Eclipse, stop a currently-running Web Server by typing `Control-C` in the console window from which you started the server.

To run GreenPages from within Eclipse:

1. Right click on the Web Server instance in the Servers view and select the Add and Remove… menu item.

2. Add greenpages-solution (which is the containing project or PAR) to the server and finish.

3. To start Web Server from within Eclipse right-click on the Web Server node in the Servers window and choose Start. The Servers view should now show the server and the added project:

4. Verify that GreenPages is started correctly by checking for `<DE0005I> Started par 'greenpages' version '2.0.1'.` in the Console window.

(If errors are shown implying that GreenPages failed to be installed, this may be because some dependencies were not copied to Web Server, as described in section the section called “Installing dependencies into Web Server”. Check this.)

Once installed and started GreenPages is again available from a web browser at the address http://localhost:8080/greenpages.

Prev | Up | Next
3.4 Browsing the GreenPages application | Home | 4. The Web Module