You are on page 1of 5

STEP1 : Setting up the Eclipse IDE

To get started with RAP, it's recommended to set up an Eclipse IDE with the RAP Tools installed. The
RAP Tools include useful tools for RAP application development such as a target installer and launchers
that let you start RAP applications directly from the IDE. The RAP developer's guide (which you are
currently reading) is also included.
Get a complete IDE package
The most convenient way to get the RAP Tools is using the Eclipse package for RCP and RAP
Developers from the Eclipse download page. This IDE includes everything you need to develop RCP and
RAP applications, and you can get skip to installing the target platform...
Install the RAP Tools into an existing Eclipse IDE
If you rather want to use an existing Eclipse IDE, you can also get the RAP Tools separately and install
them as an add-on:
With Eclipse up and running, select Help > Install New Softwarefrom the main menu.
Enter enter the RAP Update Site URL http://download.eclipse.org/rt/rap/1.5/tooling into the
Work with field and press Enter.
Note: The RAP 1.5 Tools can only be installed into an Eclipse 3.8 or 4.2 IDE (Juno) or later. For
older versions of Eclipse, you have to install the RAP 1.4 Tools.
After a short while, an entry labeled Rich Ajax Platform (RAP) appears in the list below. Select its
check box and click Next.
On the the next page you may review the installation details.
Accept the terms in the license agreement and click the Finish button.
The feature and plug-ins will now be downloaded from the repository and installed locally.
Confirm the following prompt to restart Eclipse.
You can also get a zipped version of the RAP Tools repository from the RAP Download page.

STEP2 : Installing a RAP Target
By default, the Eclipse IDE compiles all projects in the workspace against the running platform, i.e. all
bundles of the running IDE. But since RAP applications must be compiled against the RAP runtime, the
workspace must be configured to do so. This is done by setting the RAP runtime as the target platform.
Using the RAP Tools to install the latest target platform
When Eclipse starts on a fresh workspace, a welcome page is displayed. You can always return to this
welcome page choosing Help > Welcome from the main menu. Once there, click Overview and select the
Rich Ajax Platform (RAP) section. Choose Install Target Platform on the following page. In the
upcoming dialog confirm the default values, which starts the target installation process.
After the installation finished you are prepared to work with RAP. For your first steps you may read the
RAP Examples topic and/or the other chapters of the getting started section.
Install Target Manually
You can also install a target manually, e.g. if you want to develop against a different version of RAP or
combine RAP with other bundles. To select a target platform you can either use the Target Platform
preferences page (Window > Preferences > Plug-in Development > Target Platform) or create a target
definition file. The latter is preferable, as target definition files can be checked in into your source code
repository and shared among team members.
1. First, you may want to create a project to host your target definition files. A plain project will do
(File > New > General > Project).
2. In this new project, create a new target definition: New > Plug-In Development > Target
Definition. Chose a name like rap-custom.target and press Finish.
3. The target editor will open and show the contents of this target definition. Now, add the RAP
runtime from a p2 repository a.k.a. software site: press Add, select Software Site. You'll be
confronted with another dialog, named Add Software Site.
4. Again press Add and enter the URL of the RAP runtime repository. You find these URLs on the
RAP download page, e.g.
o for RAP 1.4: http://download.eclipse.org/rt/rap/1.4/runtime
o for RAP 1.5: http://download.eclipse.org/rt/rap/1.5/runtime
Hint: You can also install the RAP runtime directly from a download zip archive. In this case,
press Archive and select the zip file.
5. For a basic RAP target, select the category Rich Ajax Platform (RAP). This category contains two
features: The RAP runtime itself (RAP Target Components), and a set of Eclipse bundles needed
for a basic RAP target (Basic Target Requirements).
6. Important: Before you click Finish, make sure the checkbox Include required software is not
checked.
7. Activate the target platform by clicking the link Set as Target Platform in the upper right corner
of the target definition editor.

Step3 : Writing a Hello World with RAP
This document describes how to quickly create and launch a first user interface with RAP. Developing an
entire application involves more steps, that depend on the type of application setup you choose. These
steps are explained in the part on application development. If you want to create a Workbench-based
application, start with a template instead (see Examples).
Preconditions
the RAP Tools are installed
a RAP target platform is installed and active
Create a new project
First you need a project for your application. We suggest to create a plug-in project because that's the type
of projects used for developing OSGi bundles with PDE. (If you're not writing an OSGi application, you
can also create a plain Java Project here. In this case, you have to add rwt to the Java Build Path in the
next step). From the menu, select File > New > Plug-in Project. Let's call the plug-in
org.example.rap.helloworld. In the Target Platform box, choose an OSGi framework and standard to
create a bundle that is compatible with any OSGi framework.

On the second page of the wizard, disable the option Generate an activator, . This would create a
bundle activator, but we don't need that now.

Add a dependency to RWT
To display some widgets, we need a dependency to the RAP widget toolkit (RWT), which is RAP's
implementation of SWT. It is contained in the plug-in org.eclipse.rap.rwt. To add this dependency,
open the bundle manifest file META-INF/MANIFEST.MF. In the Plug-in Manifest Editor, go to the
Dependencies page. Add org.eclipse.rap.rwt to the list of Required Plug-ins and save.


Create an entrypoint
Every RAP application needs an entrypoint that creates the initial UI of the application. An entrypoint is a
class that implements the interface IEntryPoint. (As a side note, workbench-based applications can also
implement the Eclipse-specific interface IApplication).
Before creating the Java code, we need a package. It's a good practice to name the main package in a
bundle after the bundle id, so let's name the package org.example.rap.helloworld. In this package, we
create a class named EntryPoint that implements IEntryPoint. In the method createUI, we add some
SWT code. You can generate the skeleton of this code using an SWT template (type main and hit
Ctrl+Space, then select the template named mainloop). In the example below, we added a Button with the
text Hello world!:
public class EntryPoint implements IEntryPoint {

public int createUI() {
Display display = new Display();
Shell shell = new Shell( display );
shell.setLayout( new GridLayout( 1, false ) );

Button button = new Button( shell, SWT.PUSH );
button.setText( "Hello world!" );

shell.pack();
shell.open();
return 0;
}
}
Note: This template will generate a couple more lines after the shell.open(), called the SWT main loop.
You also find this code in SWT snippets. For workbench-based application, the main loop must be
present, but for our simple applications, it must be removed (read about application setups to understand
the difference).
Launch the entrypoint
Now we can already launch this entrypoint using the RWT launcher. Select Run As > RWT Application
from the context menu of the entrypoint class. A browser view should open up soon afterwards and show
your running application. More on launching RAP applications in the chapter Launching RAP
Applications.
Complete the application
Until now, we only have a project with an entrypoint. To turn this into a complete application, the
entrypoint must be registered so that the framework can find it. For a workbench application, this would
be done using an extension. Lightweight OSGi applications register the entrypoint in their application
configuration. These topics are covered in the part on application development.

You might also like