1

I'm using IntelliJ to run my app. Is there a way to relaunch the window or close the current one when hitting the run button?

This is because when I hit the run button it creates a new window every time. It gets a bit tedious/confusing to close the previous window that is running old code.

enter image description here

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
DIRTY DAVE
  • 2,523
  • 2
  • 20
  • 83

1 Answers1

1

Go to the Run menu and select Edit configurations...

Select the configuration you've been using to run your project in the left panel. Either it's the Gradle yourProjectName:desktop [run] task, or it's an Application run configuration you've created yourself.

Uncheck the box that says "Allow parallel run".

The next time you try to run it when it's already running, it will warn you that it can only run it if it kills the old process. You can check a box in this dialog to do that automatically from now on.

I've never figured a way to toggle this behavior back to how it was, but I've rarely ever needed to compare two builds side-by-side.

Tenfour04
  • 83,111
  • 11
  • 94
  • 154
  • I just saw in your screen shot in the comments that *Allow parallel run* is not checked, so that's weird! Do you really need to use a custom run configuration, though? For most purposes, you can just use the Gradle desktop->run task. – Tenfour04 Feb 20 '22 at 19:17
  • No I don't need a custom run configuration but the video tutorial I was following set one up. Where is the Gradle desktop -> run task option? And yes Allow parallel run is not checked I just tried it with and without it checked and both are still creating a new window everytime I hit run – DIRTY DAVE Feb 20 '22 at 20:50
  • 1
    By default, there's tab along the right side of the IntelliJ window with a Gradle tab. (If it's not there, go to View->Tool Windows->Gradle.) Open that Gradle tool window, and expand the tree to find desktop->Tasks->other->run. Double-click it to run it the first time. Then it will be in the run configurations. – Tenfour04 Feb 20 '22 at 23:54
  • Found it, but that still creates multiple windows though – DIRTY DAVE Feb 21 '22 at 01:48
  • Okay, after running it once, the run option changed to ```MyApp:desktop [run]``` and when hitting run it again it created a dialog and asked if I wanted to stop and rerun. (Which prevented multiple windows from creating) – DIRTY DAVE Feb 21 '22 at 01:50