Idea logo

The IntelliJ IDEA Blog

The Capable & Ergonomic Java IDE by JetBrains

Early Access Program Features How-To's

Run Targets: Run and Debug your App in the Desired Environment

It’s becoming more and more common to run the applications you’re developing in Docker containers or on remote machines, rather than in your local environment. Wouldn’t it be handy to run, test, and debug applications remotely without leaving IntelliJ IDEA? Well, our new Run Targets feature makes this possible.

Please note this is an initial version of Run Targets. We plan to make it better in future releases, so we would really appreciate your feedback on this feature.

Terminology and workflow

A target is a configured environment where the IDE will execute your code, for example, in a Docker container, on an SSH server, or in WSL. One of the key settings of a target is the language runtime. For a Java project, the language runtime is a JDK suitable for running your application, while for Maven it is the Maven version installed on the server.

When you create a target, the IDE detects the language runtime automatically, but you can change it or add more runtimes manually if needed. When you are finished configuring the target, you can select it in your run/debug configuration. After that, launch the app on the target the same way you launch it locally.

For a more detailed workflow description, please refer to our help center.

IntelliJ IDEA currently allows you to run Java applications, JUnit tests, and Maven commands from Java, Maven, and Spring Boot projects on Docker, SSH, and WSL targets.

This post will show you how to run your Spring Boot project on a target.

Docker targets

To run a project on a target via Docker, you can use either a Dockerfile that contains the instructions for building an image or just the image itself.

Let’s follow the workflow step by step.

1. To create a new target, select Run/Debug Configurations on the main toolbar and then click Edit Configurations.

In the left-hand list, choose the run configuration for which you want to add a target, and then click Manage Targets. In the Run Targets window, click the + icon, and then select Docker.

2. The New Target wizard appears. Let’s see what settings are required there.

Screen 1/3:

When you select the Build radio button, you need to enter a path to a Dockerfile. In the Optional section, you can add custom Docker build and run options. Once you fill in all the necessary fields, click Next.

If you don’t have a Dockerfile, you should select the Pull radio button. All you have to do is to enter an image tag and click Next. That’s it!

Screen 2/3:

The IDE either builds or pulls a Docker image, depending on the radio button you selected on Screen 1/3. IntelliJ IDEA automatically launches an introspection container to check if it has the JDK and tools configured to run your application. When the introspection completes, the container is removed. Click Next to continue.

Screen 3/3:

Here you should configure a language runtime. The JDK version is taken automatically from the Docker image.

When you click Add language runtime, you can add more Java or Maven configurations.

3. Once you complete all the steps and find yourself in the Run/ Debug Configurations window, the newly created target will appear in Run on.

IntelliJ IDEA will compile your Spring Boot application and then run it using the JDK from Screen 3/3.

And here’s the procedure for creating and running a remote Docker target for a Spring Boot project.

SSH targets

With the SSH target, you can copy and run (or build, in the case of Maven) your project on a remote machine with Maven or Java installed.

Create the SSH target the same way as the Docker one, but when you click the + icon, select SSH.

Then all you have to do is to enter the SSH server settings, define a path where the project will be copied, and add the desired language runtime or use the default one.

WSL targets

If you work on Windows, you can create a WSL target. Please note that your project must be located in the Windows file system.

Repeat the first step from the instructions for Docker above, but when clicking the + icon, select WSL. The IDE will detect your Linux distribution, and then the only remaining setting is the language runtime. Have a look:

That’s it for targets. We encourage you to test our Run Targets feature and share your feedback in the comments to this post or in our issue tracker.

Happy developing!

Discover more