Over a million developers have joined DZone.

Eclipse RAP 2.0 QuickStart with IntelliJ IDEA

DZone's Guide to

Eclipse RAP 2.0 QuickStart with IntelliJ IDEA

· DevOps Zone
Free Resource

Download the blueprint that can take a company of any maturity level all the way up to enterprise-scale continuous delivery using a combination of Automic Release Automation, Automic’s 20+ years of business automation experience, and the proven tools and practices the company is already leveraging.

Eclipse RAP 2.0 is finally out! As you probably know, developing Eclipse RAP or RCP applications outside of Eclipse can be challenging. Actually, even from the Eclipse IDE itself it's often no walk in the park to juggle all the tooling required to create and run a RAP application, let alone deploy it to a standalone servlet container like Tomcat as a simple WAR.

I've created a quickstart project that will get you up and running with RAP 2.0, including project files for IntelliJ IDEA 12 if that's your IDE of choice.

Bootstrap your application

Download this small ANT script to bootstrap your RAP application. Run it from the command line by supplying a default package and an application name:

# ant -f rap-quickstart.xml -Dpackage=com.example.myapp -Dappname=MyRapApp
Buildfile: C:\Users\Edvin\Projects\rap-quickstart.xml

    [mkdir] Created dir: C:\Users\Edvin\Projects\MyRapApp
      [get] Getting: http://static.tornado.no/rap/rap-template.zip
      [get] To: C:\Users\Edvin\Projects\rap-template.zip
      [get] ....................................................
      [get] ....................................................
      [get] ....................................................
    [unzip] Expanding: C:\Users\Edvin\Projects\rap-template.zip into C:\Users\Edvin\Projects\MyRapApp
   [delete] Deleting: C:\Users\Edvin\Projects\rap-template.zip
    [mkdir] Created dir: C:\Users\Edvin\Projects\MyRapApp\src\com\example\myapp
     [move] Moving 10 files to C:\Users\Edvin\Projects\MyRapApp\src\com\example\myapp

Total time: 7 seconds

This will create a folder named MyRapApp in the current folder with all the RAP dependencies and a module for your GUI ready to go. If you want, you can go right ahead and change into the MyRapApp directory and create a WAR-file ready to be deployed in your favourite servlet container just by running the default build command:

# ant
Buildfile: C:\Users\Edvin\Projects\MyRapApp\build.xml

    [mkdir] Created dir: C:\Users\Edvin\Projects\MyRapApp\build

    [javac] Compiling 10 source files to C:\Users\Edvin\Projects\MyRapApp\build

     [copy] Copying 4 files to C:\Users\Edvin\Projects\MyRapApp\build
     [copy] Copying 49 files to C:\Users\Edvin\Projects\MyRapApp\dist
      [jar] Building jar: C:\Users\Edvin\Projects\MyRapApp\dist\WEB-INF\plugins\com.example.myapp_1.0.0.1.jar
      [jar] Building jar: C:\Users\Edvin\Projects\MyRapApp\ROOT.war

Total time: 2 seconds

You now have ROOT.war that clocks in at a little less than 12MB, including the OSGI runtime, the RAP and JFace binaries and your project module.

You can open the supplied project.ipr in IntelliJ IDEA and get coding right away. The project includes a minimal sample View and a sample Editor for your convenience.

As per default, the OSGI console will start together with your servlet container. If you start Tomcat from the command line, you can actually interact with the console directly after the application is ready. Listing the activated bundles yields:

osgi> lb
   ID|State      |Level|Name
    0|Active     |    0|OSGi System Bundle (3.8.1.v20120830-144521)
    1|Active     |    4|International Components for Unicode for Java (ICU4J) Replacement plug-in (4.4.2.v20110831)
    2|Active     |    4|JAXP XML (1.3.4.v201005080400)
    3|Active     |    4|MyRapApp (
    4|Active     |    4|Apache Felix Gogo Command (0.8.0.v201108120515)
    5|Active     |    4|Apache Felix Gogo Runtime (0.8.0.v201108120515)
    6|Active     |    4|Apache Felix Gogo Shell (0.8.0.v201110170705)
    7|Active     |    4|Commands (3.6.1.v20120814-150512)
    8|Active     |    4|Eclipse Content Mechanism (3.4.200.v20120523-2004)
    9|Active     |    4|JFace Data Binding (1.4.1.v20120521-2329)
   10|Active     |    4|JFace Data Binding for JavaBeans (1.2.200.v20120523-1955)
   11|Active     |    4|JFace Data Binding Observables (1.4.1.v20120521-2329)
   12|Active     |    4|JFace Data Binding (1.4.100.v20120523-1955)
   13|Active     |    4|Expression Language (3.4.401.v20120627-124442)
   14|Active     |    4|Eclipse Jobs Mechanism (3.5.300.v20120622-204750)
   15|Active     |    4|Core Runtime (3.8.0.v20120521-2346)
   16|Active     |    4|Equinox Application Container (1.3.100.v20120522-1841)
   17|Active     |    4|Common Eclipse Runtime (3.6.100.v20120522-1841)
   18|Active     |    4|Console plug-in (1.0.0.v20120522-1841)
   19|Active     |    4|Http Service Registry Extensions (1.1.200.v20120522-2049)
   20|Active     |    4|Http Services Servlet (1.1.300.v20120522-1841)
   21|Active     |    4|Servletbridge Http Service (1.0.300.v20120522-2049)
   22|Active     |    4|Eclipse Preferences Mechanism (3.5.0.v20120522-1841)
   23|Active     |    4|Extension Registry Support (3.5.200.v20120522-1841)
   24|Active     |    4|Servletbridge (1.2.200.v20120522-2049)
   25|Active     |    4|Help System Core (3.6.0.v20120521-2344)
   26|Active     |    4|OSGi Release 4.2.0 Services (3.3.100.v20120522-1822)
   27|Active     |    4|RAP JFace (
   28|Active     |    4|RAP JFace Data Binding for SWT and JFace (
   29|Active     |    4|RAP Widget Toolkit (RWT) (
   30|Active     |    4|RWT-OSGi Integration (
   31|Active     |    4|RAP Eclipse UI (
   32|Active     |    4|RAP Eclipse Forms (
   33|Active     |    4|RAP Views (
   34|Active     |    4|RAP Workbench (
   35|Resolved   |    4|Servletbridge Extension bundle (1.2.100.v20120522-2049)

To run the project from IntelliJ IDEA you open the project.ipr and create a run configuration for the already supplied app:war artifact. Click Run -> Edit configurations, Add (+) -> Tomcat Server -> Local and choose the Deployment tab. From there, click the plus, and choose the already populated app:war artifact. Next, run the configuration and your application will be automatically deployed to Tomcat.

Configure IDEA Run Configuration

Hot code deploy is supported, and every time you make your project, the module artifact and the WAR artifact are automatically rebuilt. The RAP source code is attached as well, so you have documentation and sources available directly in IDEA.

If you take a look at the application in your browser, you should see something like this:


Changes to the editor should enable the save button, and clicking save should reset the dirty state. If you are having issues or wondering about details, please let me know and I'll try to help out. Good luck!

Download the ‘Practical Blueprint to Continuous Delivery’ to learn how Automic Release Automation can help you begin or continue your company’s digital transformation.


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}