Overview

Skill Level: Any Skill Level

Step-by-step

  1. Install a JDK, Eclipse and WDT.

    1. Download and install a Java Development Kit (JDK). This is required to develop Java apps. Java EE 7 is the latest supported version, so it is recommended that you use JDK 7.1 or 7.

    2. Download and install Eclipse 4.5 for Java EE Developers (Mars). This is the Integrated Development Environment (IDE) you will be using to develop your enterprise applications.

    3. Add the WebSphere Development tools (WDT) to Eclipse. Drag and drop the install button below on to the toolbar in Eclipse.

    The tool bar where the install link is to be dropped.

    4. Press Confirm and wait for the green bar to fill. Read and accept the terms of the license agreement, then click Finish.

    WDT for Eclipse will now be downloaded and installed.

    You may be prompted to restarted eclipse, if so click yes to restart it.

    Note: If you wish to verify that you installation was successful, go to Help > About Eclipse and on the window that opens, click Installation Details. There you should find the WebSphere Application Server Liberty Profile Tools listed.

  2. Install the Liberty Runtime, and Create a WAS Liberty Server.

    The simplest way to get the latest Liberty Profile Runtime, which is needed to run your apps, is to go through the process of creating a WAS Liberty Server.

    1. Go File > New > Other, and where it says ‘type filter text‘, enter server. Make sure Server is highlighted and click Next.

    2. Make sure ‘WebSphere Application Server Liberty Profile‘ is selected, then press Next.

    3. Make sure ‘Install from an archive or repository‘ is checked, then click Next.

    4. Fill the destination path with where you would like your liberty installation path to be located. For example, C://Users/Admin/Liberty.

    5. Check ‘Download and install a new runtime environment from ibm.com:‘, and then select the latest version of the WAS Liberty Runtime. Click Next.

    6. Here you have the option to install different add-ons to the runtime environment, but for now lets skip this by clicking Continue.

    7. Read and accept the terms of the licence agreement, and click Next.

    8. Now you have the option to name your server. Either change the server name or leave it as default, and then click Finish.

    The runtime is now downloaded and installed!

  3. Create a New Web Project

    1. Ensure you are in either the web or java ee perspective, and open the Web Project creation wizards by going File > New > Web Project. If the Web Project option is not present, look for it by selecting Otherfrom the drop down menu.

    2. 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.

    3. Ensure Deployment is selected and by Target Runtime select WebSphere Application Server Liberty Profile.

    4. Make sure the Add project to an EAR check box is not checked, and click Finish.

  4. Create the Hello World App

    1. To create the simple JSP used in this example, right-click the Hello World project and click New > Web Page.

    2. Enter index.jsp as the File name and ensure that Basic Templates > JSP is selected. Click Finish.

    WDT will create and open the JSP for you.

    3. First of all, lets give the JSP an appropriate title. To do this, update index to be Hello World.

    4. 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 (CMD-Space on a mac) after typing the class name. This will add the following imports at the top of the jsp file:

    <%@page import=”java.util.Calendar”%>
    <%@page import=”java.util.GregorianCalendar”%>

    5. Save the file. We are now ready to deploy our application.

    6. Right click on the .jsp Hello World and select Run As > Run on Server.

    7. Select the Server we created earlier and click finish.

    8. 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 itll run the application from the Eclipse workspace, to give you the fastest edit, compile, run, debug cycle possible.

Join The Discussion