Liberty and Eclipse: Create a server

5 min read

Liberty and Eclipse: Create a server

WebSphere Liberty is the next generation application server. Liberty and Eclipse make a great local development environment for developing Java EE applications. One task you’ll need to be able to perform is using Eclipse to create a new Liberty server. This will be the local server you’ll deploy your Java EE app into so you can test it locally.

logo

In this excerpt from “Java EE, the next inception: Install a local Java EE development environment for WebSphere Liberty,” we’ll explore how to create a new Liberty server using Eclipse. Next, we’ll discuss another common development task: Using Eclipse to download an install a Liberty asset.

To start at the beginning of this series, see WebSphere Liberty: Developing Java EE applications for the cloud.

Create a server using Eclipse

Once you have installed a Liberty profile, you will also need to create at least one server in that profile.

The steps that follow describe the process for setting up a Liberty server in Eclipse using a Liberty profile that has already been installed locally. All of this can be done in a single dialog, the New Server dialog (see Getting started with WebSphere Developer Tools for Eclipse and Liberty), but if you are new to Eclipse and Liberty, you will probably find this process easier to understand because it creates the artifacts in discrete steps:

  1. Create a runtime environment in Eclipse that links to the Liberty profile.

  2. Create a server in the Liberty profile.

  3. Create a server in Eclipse that links to the Liberty server.

These steps assume you are using Eclipse as your Java IDE with the WebSphere Developer Tools installed. These steps require a handful of variables, shown in Table 1. The example values assume the Liberty profile is version 8.5.5.6.

Table 1. Eclipse server creation variables

Table 1. Eclipse server creation variables

 

Create a runtime environment in Eclipse

First, create a runtime environment in Eclipse that links to the locally installed Liberty profile. Using the WebSphere Developer Tools in Eclipse:

  1. In the Runtime Explorer view, select New > Runtime Environment (Figure 1).

    Figure 1. New runtime environment

    Figure 1. New runtime environment
  2. In the Liberty Profile dialog (Figure 2):

    • Set the Name to <Environment_Name>.

    • Select Choose an existing installation with the Path <Liberty_Path>.

    • Select Use default JRE (or specify the JRE your applications require).

    • Press Finish.

    Figure 2. Create runtime environment

    Figure 2. Create runtime environment

You have now linked a runtime environment in Eclipse to a Liberty profile installed outside of Eclipse. The next steps are to create a server and link to it from Eclipse.

Create a Liberty server

Next, create a server in the Liberty profile. If you already have an existing server, skip to the next step to link Eclipse to the server. If you need to create a server in a profile you have already linked to from Eclipse, you can do so here.

To create a server in the profile using the WebSphere Developer Tools in Eclipse:

  1. In the Runtime Explorer view, select the runtime environment you just created, <Environment_Name>. Select New > Liberty Profile Server (Figure 3).

    Figure 3. New Liberty profile server

    Figure 3. New Liberty profile server
  2. In the New Liberty Profile Server dialog (Figure 5):

    • Confirm the User directory is <Environment_Name>.

    • Set the Server name to <Liberty_Server_Name>.

    • Confirm the Template is defaultServer.

    • Press Finish.

    Figure 4. Create Liberty profile server

    Figure 4. Create Liberty profile server

You have now used Eclipse to create a server in a Liberty profile. The next step makes that server available in Eclipse.

Create a server in Eclipse

To create a server in Eclipse that links to the locally installed Liberty server using the WebSphere Developer Tools in Eclipse:

  1. In the Servers view, select New > Server.

  2. On the Define a New Server page in the New Server dialog (Figure 5):

    • Select the Server Type IBM > WebSphere Application Server Liberty Profile.

    • Confirm the Server’s host name is localhost.

    • Select the Server runtime environment <Environment_Name>.

    • Set the Server name to <Eclipse_Server_Name>.

    • Press Next.

    Figure 5. Define a new server

    Figure 5. Define a new server
  3. On the Liberty Profile Server panel (Figure 6):

    • Confirm the Liberty profile server is <Liberty_Server_Name>.

    • Press Finish.

    Figure 6. Liberty profile server

    Figure 6. Liberty profile server

At this point, you have now created a server named <Liberty_Server_Name> in the Liberty profile installed in <Liberty_Path>, and created a link to it in Eclipse named <Eclipse_Server_Name> in the runtime environment <Environment_Name>. The new server is installed in this path:

<Liberty_Path>/usr/servers/<Liberty_Server_Name>

Because Eclipse is linked to the server, you can use Eclipse to manage the server, which means you can deploy Eclipse projects to the server.

—Bobby Woolf (@bobby_woolf)

Be the first to hear about news, product updates, and innovation from IBM Cloud