Developing applications with IntelliJ IDEA and Liberty profile

When we first released the Liberty profile we also released some great tools for developing applications with Eclipse, but what if you aren’t using Eclipse? What if you are using (as an example) IntelliJ IDEA?

Well, fear not because the awesome guys at JetBrains have released support in IntelliJ IDEA for developing applications with Liberty profile. As you might imagine if you are used to using IntelliJ it is integrated nicely into the IDE as you would expect for any other Java EE runtime.

Disclaimer:- I’m an Eclipse user, my first experience of IntelliJ IDEA was trying to write this article, so if you are an expert and I talk about doing something a dumb way I’m happy for you to let me know and I’ll update this article.

I thought I would develop a very simple Hello World application using IntelliJ and document my experience, just to show how easy it is.

  1. The first step is to download and install IntelliJ IDEA Ultimate Edition (for Java EE support). You want the latest release of version 12. Sounds kind of obvious but, once you’ve installed it, you should launch the IDE.
  2. The first step in IntelliJ is to create a project. This is simple using File > New Project.
  3. In the new Project wizard, select JavaEE Web Module and enter Hello World as the project name, provide the project location, and then click Finish.
    Screen Shot 2013 09 25 at 11.19.33 Developing applications with IntelliJ IDEA and Liberty profile
  4. The new project will contain an index.jsp under the Hello World > web folders. Open this file and we will start editing it.
    Screen Shot 2013 09 25 at 11.22.11 Developing applications with IntelliJ IDEA and Liberty profile
  5. First of all, let’s give the jsp an appropriate title. To do this, update index to be Hello World
  6. Between the <body> and </body> tags add:
    <h1>Good <% if (new GregorianCalendar().get(Calendar.HOUR_OF_DAY) < 12) {%>  
       Morning
    <% } else { %>
       Afternoon
    <% } %></h1>
  7. Make sure the following imports are at the top of the JSP
    <%@ page import="java.util.Calendar" %>
    <%@ page import="java.util.GregorianCalendar" %>

    Screen Shot 2013 09 25 at 11.30.27 Developing applications with IntelliJ IDEA and Liberty profile

  8. Save the file. We are now ready to deploy our application.
  9. Click the Run menu and select Run. Since we haven’t run anything before this will pop up a dialog. Click Edit Configurations… in the dialog.
    Screen Shot 2013 09 25 at 13.47.20 Developing applications with IntelliJ IDEA and Liberty profile
  10. Click the + button, scroll to the bottom of the list and select WebSphere Server, then click Local.
    Screen Shot 2013 09 25 at 16.22.03 Developing applications with IntelliJ IDEA and Liberty profile
  11. Enter Hello World Server as the name of the run configuration.
  12. Next, you need to configure the location of the server installation. I’m assuming that you have already downloaded and installed the runtime, so click Configure.
    Screen Shot 2013 09 25 at 16.22.46 Developing applications with IntelliJ IDEA and Liberty profile
  13. Provide the path to the installation of Liberty profile and click OK.
    Screen Shot 2013 09 25 at 11.37.31 Developing applications with IntelliJ IDEA and Liberty profile
    IntelliJ can even detect the version of Liberty you have installed.
  14. Next, switch to the Deployment tab.
  15. It says there is nothing to deploy. To fix that, click the + button, then click Artifact.
    Screen Shot 2013 09 25 at 16.26.05 Developing applications with IntelliJ IDEA and Liberty profile
  16. Finally, click Run.
  17. This will open another run dialog, but this time you just click Run.
    Screen Shot 2013 09 25 at 11.57.05 Developing applications with IntelliJ IDEA and Liberty profile

IntelliJ will launch deploy the application, start the server, and open a web browser for you.

The tools don’t appear to have as much function as the WebSphere Developer Tools; for example, you can’t download and install the runtime from the tools and there doesn’t seem to be a built-in server configuration editor. But if your IDE of choice is IntelliJ, you are good to go.