Setup an Apache Pivot project in Eclipse

Apache Pivot logoApache Pivot is an open-source platform for building rich web applications in Java. I was looking for a modern UI toolkit and Pivot is exactly that. I’m willing to give a try so I tried to setup some Pivot projects in Eclipse. It actually comes with an Eclipse plugin that simplifies development of Pivot applications.

So here is a quick guide to setup Eclipse for the development of Pivot applications

Install Eclipse Plugin for Apache Pivot

The Eclipse plugin provides a run configuration so you can easily run your Pivot projects inside Eclipse.

Create a Pivot project in Eclipse

  1. Create a New Java Project in Eclipse, name it (e.x. HelloBXML) and click Finish.
  2. Create a new Java Project in Eclipse
    Create a new Java Project in Eclipse
  3. Add a lib folder in your new Java project. Right click on your project in Package Explorer -> New -> Folder
  4. Copy the Pivot JARs you need to the lib folder. Right click on lib folder in Package Explorer -> Import.
  5. Select General -> Filesystem and hit Next. Hit Browse on From Directory and browse to apache-pivot/lib directoy. Select all the JARs you want. At minimum you’ll need pivot-core.jar, pivot-wtk.jar and pivot-wtk-terra.jar
  6. Import the Pivot JARs into the lib folder
    Import the Pivot JARs into the lib folder
  7. Right click on your project and select Properties. Go to Java Build Path -> Libraries and hit Add JARs… to add Pivot in your build path.
  8. Add Pivot libraries in your build path
    Add Pivot libraries in your build path

Setup Pivot source code references in Eclipse

Let’s add a reference to the Pivot source code in Eclipse

  1. First you need to download the Apache Pivot source code and extract it in your Pivot Binary Distribution folder.
  2. Expand Referenced Libraries in Package Explorer and right click on the library name (e.g. pivot-core-2.0.jar) and select Properties.
  3. Go to Java Source Attachment and click External Folder.
  4. Browse to the folder you extracted the Source Distribution and point to appropriate library (e.g. pivot-core.2.0.jar –> core/src)
  5. Reference to the Pivot source code
    Reference to the Pivot source code
  6. Do the same for the rest libraries

Setup Pivot JavaDoc in Eclipse

  1. Expand Referenced Libraries in Package Explorer and right click on the library name (e.g. pivot-core-2.0.jar) and select Properties.
  2. Go to Javadoc Location and in Javadoc URL Browse to the doc folder in your Pivot Binary Distribution folder (e.g. apache-pivot-2.0/doc/).
  3. Setup Pivot JavaDoc in Eclipse
    Setup Pivot JavaDoc in Eclipse

Run HelloBXML tutorial’s example

  1. Create a New Class named HelloBXML
    Create a Pivot Class
    Create a Pivot Class
  2. Copy the class code from the HelloBXML tutorial
  3. Add a New File hello.bxml and copy the BXML xml from the HelloBXML tutorial
  4. Right Click on HelloBXML.java in Package Browser and select Run As -> Pivot Application
  5. The HelloBXML application should launch.

Resources:
Apache Pivot – FAQ
Download Apache Pivot Eclipse Plugin

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive