blob: 23218aa504b5e7aadedbc37cbf06e440aed5bd52 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
<meta name="copyright" content="Copyright (c) 2007, 2013 EclipseSource. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page."/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Writing a Hello World with RAP</title>
<link rel="stylesheet" href="../../../PRODUCT_PLUGIN/book.css" type="text/css"/>
<h1>Creating a Hello World with RAP</h1>
This document describes how to quickly create and launch a first user interface with RAP.
A complete application includes a few more components, depending on your
<a href = "application-setup.html">application setup</a>.
<li><a href="setup-ide.html">the RAP Tools are installed</a></li>
<li><a href="target-install.html">a RAP target platform is installed and active</a></li>
<h2>Create a new project</h2>
First we need to create a project for your application.
It is recommended to use a <em>Plug-in Project</em>,
unless you want to write an <a href="?topic=rwt-standalone&amp;version=2.0">RAP applications
without OSGi</a>. In the latter case, you can also create a plain <em>Java Project</em> here.
(If you do so, the project setup will differ slightly from this tutorial. Most notably, you
will have to add <em>org.eclipse.rap.rwt</em> to the java build path/
<em class="UILabel">Required Projects</em> in the next step.)
From the menu, select <em class="UILabel">File &gt; New &gt; Plug-in Project</em>.
Let's call the plug-in <code>org.example.rap.helloworld</code>.
In the <em class="UILabel">Target Platform</em> box, choose
<em class="UILabel">Eclipse version</em> and <em class="UILabel">3.5 or greater</em> to create a
bundle that is compatible with Eclipse.
<img src="../images/hello-world/NewProject-1.png" alt="New Project Wizard"/>
On the second page of the wizard, disable the option
<em class="UILabel">Generate an activator</em>.
(This option would create a bundle activator, but we don't need that now.)
Ensure that no <em class="UILabel">Rich Client Application</em> will be created.
<img src="../images/hello-world/NewProject-2.png" alt="New Project Wizard"/>
On the next page select the <em class="UILabel">RAP Hello World</em> template.
<img src="../images/hello-world/NewProject-3.png" alt="New Project Wizard"/>
Set the <em class="UILabel">Application window title</em> and
<em class="UILabel">Package name</em> and click "Finish".
<img src="../images/hello-world/NewProject-4.png" alt="New Project Wizard"/>
The wizard will create all needed classes for your RAP application.
<h2 id="entrypoint">Create the application UI</h2>
Every RAP application needs an entry point class that creates the initial UI of the application.
The wizard automatically creates a class named <em>BasicEntryPoint</em> that extends
<em><a href="../reference/api/org/eclipse/rap/rwt/application/AbstractEntryPoint.html">AbstractEntryPoint</a></em>
in the speified package. In the method
<em><a href="../reference/api/org/eclipse/rap/rwt/application/AbstractEntryPoint.html#createContents(org.eclipse.swt.widgets.Composite)">createContents</a></em>,
we already have some SWT code with two buttons.
<pre class="lang-java">
public class BasicEntryPoint extends AbstractEntryPoint {
protected void createContents(Composite parent) {
parent.setLayout(new GridLayout(2, false));
Button checkbox = new Button(parent, SWT.CHECK);
Button button = new Button(parent, SWT.PUSH);
} </pre>
<h2>Launch the application</h2>
Now we can launch this application using the generated launch configuration
<em>org.examples.rap.helloworld.launch</em> in the project root.
Select <em class="UILabel">Run As &gt; org.examples.rap.helloworld</em> from the context menu
of the launch configuration file.
A browser view should open up soon afterwards and show your running application.
More information on launching RAP applications can be found in the chapter
<a href="./launcher.html">Launching RAP Applications</a>.