Effective cloud-native Java app development with Open Liberty in IntelliJ IDEA

See how you can use Liberty Tools for IntelliJ IDEA to enable rapid, easy, and efficient development of cloud-native Java applications with Open Liberty and WebSphere Liberty

When it comes to integrated development environments, within the Java community, IntelliJ IDEA is the most popular IDE amongst professional developers. It is the preferred IDE of choice by two-fifths of developers, making up the biggest majority of IDE users in this community, according to JRebel’s 2023 Java Developer Productivity Report.

This well-established and highly popular IDE provides a fantastic and highly efficient environment in which to develop effective cloud-native Java applications, significantly improving the development experience. However, in order to truly unlock this improved development experience and enhanced productivity, we must ensure we have the most appropriate and useful plugins.

In this article, we’ll explore the Liberty Tools plugin for IntelliJ IDEA and how this can help enable fast, easy and efficient development of cloud-native Java applications with both Open Liberty and WebSphere Liberty.

If you’ve not heard of Open Liberty before, Open Liberty is a lightweight, open framework, great for building fast and efficient cloud-native Java applications. To learn more about what Liberty can offer, check out the “Six reasons why Open Liberty” and “Why cloud-native Java developers love Liberty” articles. Alternatively, you can get hands-on with this cloud-native runtime with our Getting started with Open Liberty guide.

The open source Liberty Tools for IntelliJ IDEA, is a useful plugin when developing your application with Open Liberty. The Liberty Tools are a set of intuitive developer tools that provide a simplified yet powerful development experience and support popular IDEs, including IntelliJ IDEA, Eclipse IDE, and Visual Studio Code.

The Liberty Tools for IntelliJ IDEA plugin can help with all stages of the extended development lifecycle now expected from cloud-native development teams, including helping you in developing, building, testing, deploying, and managing your applications – all within your favorite IDE, IntelliJ!

Key Capabilities of Liberty Tools

These tools introduce capabilities that really empower you to develop, test, debug, and manage applications without having to leave your IDE, including:

Easily view and access all detected Liberty projects in your IDE in the Liberty tool window
Rapid, iterative development with Liberty dev mode
Effective testing and debugging all within the IDE
Editing assistance for you to easily make changes to your Liberty configuration files
Coding assistance for you to write applications that use Jakarta EE (9.x and later) and MicroProfile (3.x and later) APIs, including validations, quick fixes, and completions

In this article, we’ll dive further into these capabilities. If you want to view a deep dive tutorial on this tool, then watch the Developer Deep Dive of Liberty Tools for IntelliJ IDEA video.

View and access all detected Liberty projects in your IDE in the Liberty tool window

Liberty Tools automatically detects Liberty Maven or Gradle projects. These projects are added to a special Liberty tool window in the IntelliJ IDEA. This can be accessed through the Liberty tab available in the menu on the very right-hand side of the IDE.

From this window, you can access a command menu to manage your Liberty projects. What this means, is that you now don’t have to spend time creating and managing Liberty instances, freeing up your time to focus on the code itself and enabling greater developer productivity in your teams.

Rapid, iterative development with Liberty dev mode

Liberty’s hot reload functionality, named “dev mode”, enables automatic detection, recompilation, and deployment of code changes whenever you save a new change. Liberty dev mode enables rapid, iterative development in a manner that aligns with agile development practices that are recommended for cloud-native applications.

It can also run unit and integration tests automatically after changes and can attach a debugger to the running server to step through your code at any time. Liberty Tools brings these dev mode features directly into the command menu for the Liberty projects in your editor. With just a few clicks, you can start and stop your Liberty application, run tests, and view test reports.

To try this for yourself, follow the steps in the Liberty Tools user guide to run your application on Liberty using dev mode.

You can also run your application in dev mode in a container through the ‘Start in container’ action. When dev mode runs with container support, it builds a container image and runs the container. For more information on dev mode for containers, check out the Liberty Maven devc goal or, alternatively, see the Liberty Gradle libertyDevc task.

Effective testing and debugging within the IDE

When your application is running on Liberty using dev mode, you can easily run the tests provided by your application. To do this, select the ‘Run tests’ command in the Liberty tool window, or alternatively, you can simply press enter in the terminal running Liberty in dev mode.

Additionally, you can also configure Liberty to automatically re-run tests after you’ve made changes by setting “hotTests” parameter to “true”. After the application tests finish running, you can access the test reports that were generated. The reports will vary depending on what build tool you have used.

You can follow the steps in the Liberty Tools user guide to run your application’s tests and view your application’s test results.

You can use the Liberty run/debug configuration to customize the parameters for the dev mode start command and to start dev mode with the debugger automatically attached to the Liberty server JVM that runs your application.

To do this, you’ll first need to create or select a Liberty Run/Debug Configuration through the IntelliJ Run/Debug Configuration menu, and then select the Debug action in the IDE menu. If you’re unsure of how to create a new Liberty run/debug config, you can access detailed instructions on how to achieve this in the Liberty Tools for IntelliJ IDEA User Guide.

For more on this, you can see the steps required in the Liberty Tools user guide section: debug your application.

Editing assistance for configuration files

You can also use Liberty Tools to get Liberty configuration editing assistance through the Liberty Config Language Server, such as code completion, diagnostics, and quick-fixes, in Liberty server.xml, server.env, and bootstrap.properties files.

To use Liberty-specific code completion, press Ctrl + Space or Cmd + Space and a drop-down list of completion suggestions will appear. In addition to this, by hovering over existing features defined within the server.xml, a description for each of these will also appear, helping developers to know exactly what they’re using in their applications.

This hover-over support is also enabled for other xml elements too. All of this saves developers time and additionally means that they don’t have to go and find the correct documentation to find this information – promoting further productivity gains. Follow the steps in the Liberty Tools user guide for configuring a Liberty server with configuration assistance to try this for yourself.

Coding assistance for Jakarta EE and MicroProfile APIs

Another feature offered by the Liberty Tools plugin is coding assistance. This provides helpful language-support features such as code completion, diagnostics, and quick-fixes in configuration and application files for Jakarta EE and MicroProfile APIs.

Just as with the editing assistance, this can also be accessed by pressing Ctrl + Space or Cmd + Space and a drop-down list of code snippet suggestions appears. This can range from creating an entire REST class, to adding POST, GET, DELETE methods, and more.

The Jakarta EE API coding assistance is offered through Eclipse LSP4Jakarta and the MicroProfile EE API coding assistance is offered through Eclipse LSP4MP, the Language Servers for Jakarta EE and MicroProfile.

If you’d like further resources for this, you can explore the Liberty Tools user guide and follow the steps laid out in this to develop with Jakarta EE and MicroProfile APIs with coding assistance.

Start using Liberty Tools in IntelliJ IDEA

Before you can use Liberty Tools in IntelliJ IDEA, you must satisfy these requirements:

Java 17 (or later) is needed to run the extension (but you can choose a different version of Java to run your application)
IntelliJ IDEA 2023.1 or later

NOTE: (IntelliJ IDEA 2023.1 and above come bundled with Java 17)[https://intellij-support.jetbrains.com/hc/en-us/articles/206544879-Selecting-the-JDK-version-the-IDE-will-run-under?], so no extra set up is required

Install the Liberty Tools for IntelliJ IDEA plugin either from the JetBrains marketplace or directly from the IDE
Liberty Maven plugin or Liberty Gradle plugin configured in the pom.xml or build.gradle file for your app. Use the most recent version of the plugin to get important bug fixes.

There are comprehensive instructions for how to install and use this plugin available on GitHub.

When installed, the Liberty tool window and corresponding Liberty actions are available in the Liberty tab on the right-hand side of the IDE.

The Liberty tool window is automatically populated with detected projects that are already properly configured to run on Liberty and use Liberty dev mode.

If you do not have any apps in your current workspace, you can create a starter application and import.

Once you import an app, refresh the Liberty tool window tab by clicking the refresh icon in the IDE.

Summary and next steps

With the Liberty Tools plugin for IntelliJ IDEA, you can efficiently develop, deploy, debug, test, and manage your cloud-native Java applications.

Now that you have Liberty Tools set up in your IDE, why not try using it with some of the Open Liberty guides or tutorials?

Sponsored Content

Jakarta EE 11: Beyond the Era of Java EE

This user guide provides a brief history of Java EE/Jakarta EE and a detailed overview of some of the specifications that will be updated in Jakarta EE 11.


Get Started

The post Effective cloud-native Java app development with Open Liberty in IntelliJ IDEA appeared first on foojay.