The Liberty app accelerator generates a basic application that you can build and deploy to a Liberty server using Maven.

In this short tutorial, we’ll use the Liberty app accelerator to project containing a simple Java servlet.

Generating a project using the Liberty app accelerator

  1. Head to the Liberty app accelerator.

  2. The app we’re creating will be a simple Java servlet, so click Servlet:


  3. Accept the default options and download the project ZIP file:


  4. Extract the ZIP file into a directory. Now you’re ready to go:

Building and running from the command line

  1. Ensure you have the Maven command line client installed.

  2. From the command line, change to the directory that contains your extracted application files.

  3. Run the following command to build and run the application:

    mvn install liberty:run-server
  4. Access your application at the URL shown on the Liberty app accelerator page (e.g. http://localhost:9080/myLibertyApp/). Your application should look something like this:


    Appcelerator-result

  5. To edit the application, make changes to the LibertyServlet.java file.

Building and running from Eclipse

  1. Download and start Eclipse.

  2. Import the project into Eclipse:

    1. In the Java EE perspective of Eclipse, click File > Import… then click Projects from Folder or Archive.
    2. Browse to the directory into which you extracted the ZIP file, then click Finish. The project is displayed in the Project Explorer view:


  3. Right-click the project and click Maven build….

  4. In the Goals field, type install liberty:run-server, then click Run. This builds the application and deploys it to a Liberty server:


  5. Access your application at the URL shown on the Liberty app accelerator page (e.g. http://localhost:9080/myLibertyApp/). Your application should look something like this:


    Appcelerator-result

  6. To edit the application, make changes to the LibertyServlet.java file.

What next?

Try generating other types of Liberty applications from the Liberty app accelerator. The Liberty app accelerator is a project in GitHub.

Join The Discussion

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