How to download and run the Java EE 7 sample applications in Eclipse with WebSphere Developer Tools (WDT).

There are some application samples for WebSphere Application Server (WAS) V9 available on GitHub that make it easy to check out selected Java EE 7 technologies on Liberty using Eclipse with the WebSphere Developer Tools, (WDT). Here’s how you do it…

Getting started

Download and install WebSphere Developer Tools for Mars Eclipse. When you create a new server and are prompted to install the Liberty runtime, select the WAS Liberty with Java EE 7 Web Profile option to get the Java EE 7 Web Profile subset of Liberty features.

If you’re new to WDT, take a look at Getting started with WebSphere Developer Tools for Eclipse and Liberty.

You should immediately see that the new Liberty server has been added. Don’t worry about any errors for now. The server.xml will get updated later.

Cloning a project from GitHub using Eclipse

The next step is to choose a sample from GitHub and clone it on to your local Eclipse machine:

  1. In Eclipse, click Window > Show View > Other.
  2. Expand Git.
  3. Select Git Repositories, then click OK.
  4. You will now see a Git Repositories tab and three links. Click the Clone a Git Repository link.
  5. Type in the URL for the repository you wish to clone (do not add ‘www’ to the domain, as this will fail). For example:
    https://github.com/WASdev/sample.javaee7.jsonp/
  6. Follow the rest of the wizard but do take note of the destination folder where you save the repo.

Import your local Maven clone project into Eclipse

To get the Maven project into Eclipse:

  1. Click File > Import.
  2. Expand Maven, select Existing Maven Projects, then click Next.
  3. Click Browse, navigate to the cloned project and select it. For example, I saved mine to C:gitrepogitjavaee7-samplesjson
  4. You should see the items selected and listed under a pom.xml item that is also selected. If so, Click Finish.
  5. Check the instructions in the README.md for the sample in case there are any specific instructions to do any extra setup or provisioning that might be necessary. The README.md should tell you what changes to make to your ‘server.xml’.

Building the sample

To do the Maven build stuff (compiling and creating the build file):

  • Right-click the sample project, then click Run as > Maven > Install

Running the sample

Linking the runtime in Eclipse to our sample allows code changes to be incrementally published to the server and run immediately:

  1. Right-click the Liberty server in the Servers tab.
  2. Click Add and Remove…, then add the sample.javaee7 project to the server.
  3. Click Finish.
  4. Start the server.
  5. When you see the link that says localhost:9080/sample_name/ in the console output, click it to bring up the sample application.

If you have any questions, ask them on Stack Overflow.

If you’re interested in trying out more Java EE 7 samples, Kevin Sutter has written about how to run the industry open source Java EE 7 samples on Liberty.

Join The Discussion

Your email address will not be published. Required fields are marked *