Developing applications with WDT and Liberty profile

Following on from our introduction to using IntelliJ, we thought we’d explain how to use our very own WAS Developer Tools to write the same Hello World app.

Two weeks ago we published an article on how to use IntelliJ IDEA to develop applications with Liberty profile. We realised this would make a good start to a series of articles: Developing applications with XYZ development tool and Liberty profile.

The best way to start a series is to write a second article. So this is that second article. It looks at using WebSphere Application Server Developer Tools for Eclipse (typically known as WDT because that is short and not a mile wide) and, throughout the series, we’ll use a simple Hello World application so that we can show how to develop it using various development tools.

  1. The first step is to download and install Eclipse IDE for Java EE Developers. You want the Juno SR2 release.
  2. The second step is to install WDT into the eclipse environment. This can be done from the Eclipse Marketplace client, or from the web via the Eclipse Marketplace entry, or from this site.
  3. Once you have WDT installed (and the IDE running) the first step is to create a project. This is simple to do from the Web or Java EE perspectives using File > New > Web Project.
  4. In the new Project wizard, enter Hello World as the project name, ensure that the project template is Simple and the Programming Model is Java EE, and then click Next.
    new web project Developing applications with WDT and Liberty profile
  5. Ensure Deployment is selected and by Target Runtime click New….
  6. Select WebSphere Application Server V8.5 Liberty Profile and click Next.
    new server runtime Developing applications with WDT and Liberty profile
  7. Enter the path to your Liberty profile installation and click Finish. If you don’t yet have the Liberty profile installed you can click the download or install link just above the path to download and install Liberty from IBM.com.
    server install Developing applications with WDT and Liberty profile
  8. Clear the Add project to an EAR check box and click Finish.
  9. To create the simple JSP used in this example, right-click the Hello World project and click New > Web Page.
  10. Enter index.jsp as the File name and ensure that Basic Templates > JSP is selected. Click Finish.
    new jsp Developing applications with WDT and Liberty profile
    WDT will create and open the JSP for you.
  11. First of all, let’s give the JSP an appropriate title. To do this, update index to be Hello World
  12. Between the <body> and </body> tags add:
    <h1>Good <% if (new GregorianCalendar().get(Calendar.HOUR_OF_DAY) < 12) {%><br />Morning<br /><% } else { %><br />Afternoon<br /><% } ></h1>

    WDT will automatically add imports to the JSP for the Java classes being used if you press CTRL+Space after typing the class name.

  13. Save the file. We are now ready to deploy our application.
  14. Right click on Hello World and select Run As > Run on Server.
  15. Since no server has been defined to the IDE we need to define one. Select Manually define a new server and select IBM > WebSphere Application Server V8.5 Liberty Profile and click Finish.
    run on server Developing applications with WDT and Liberty profile

WDT will launch deploy the application, start the server, and open the web page in the integrated web browser for you. Not only that but it’ll run the application from the Eclipse workspace, to give you the fastest edit, compile, run, debug cycle possible.