Winter
Winter

Reputation: 4095

How do I run the same application twice in IntelliJ?

I'm using IntelliJ to develop my client-server application and just discovered Compounds. Basically I can run my client and my server at the same time and it's saving me useless manipulations everytime I want to test. However, I would like to test my application with 2 clients and 1 server since it's a game and have no point being played alone. IntelliJ does not let me add the same application twice in a compound. How can I achieve that ?

What I have now: Compound configuration

Plus, I can't tell a run configuration to run itself before launch. When I click the button in the following, image, the configuration I am on does not show up.

Can't run itself

Upvotes: 61

Views: 67440

Answers (11)

Aayush Soni
Aayush Soni

Reputation: 41

For windows :

Firstly Go to the dropdown menu next to the Run/Debug buttons on the toolbar, then select "Edit Configurations...". Then do the following :

  1. copy configurations while having selected the configuration you need to copy
  2. edit the environment variables
  3. change the server port from the original server of the service
  4. save the configuration

enter image description here

Upvotes: 2

Denis Orlov
Denis Orlov

Reputation: 127

If it is a Spring Boot Application:

  1. Add(or copy) extra Run Configuration "Spring Boot"
  2. Name it somehow
  3. Copy or check if Main class is from the original configuration
  4. Open Environment variables window and add vartiable "server.port" with value witch is different from the original server.port

Run both configurations!

Running multiple instance of spring boot application in Intellij IDEA

Upvotes: 1

cpwei
cpwei

Reputation: 41

IntelliJ IDEA 2023.2.1
Build #IU-232.9559.62, built on August 23, 2023
Click Run->Edit Configurations->Modify Options->Allow Multiple Instances

Run/Debug Configurations->Modify Options

Run/Debug Configurations->Modify Options-Allow Multiple Instances

Upvotes: 4

Bui Hai Duong
Bui Hai Duong

Reputation: 271

For me, i copy the same configuration enter image description here

  1. I run my first Application.
  2. I change the port of something not to be duplicated
  3. I run my second Application.

-> It worked well.

Upvotes: 2

Tajdin
Tajdin

Reputation: 1

For Intellij:

Click Run->Edit Configurations->Modify Options->Allow Multiple Instances

Upvotes: 0

George
George

Reputation: 30341

On Mac:

Go to Run > Edit Configurations... then select the application. Click the Modify options drop-down, and turn on Allow multiple instances.

Remember to click Apply then OK.

Image showing setting to turn on

Upvotes: 19

Eljah
Eljah

Reputation: 5154

Find this in Edit Configuration:

enter image description here

Upvotes: 1

SAHIL SINGH SODHI
SAHIL SINGH SODHI

Reputation: 904

Click Run->Edit Configurations. For the file requiring multiple instances, click on Allow parallel run. You can do this for multiple files. Click on Apply. enter image description here

Upvotes: 78

Omid Mohebbi
Omid Mohebbi

Reputation: 786

I had same problem with Intellij 2018.2.5 and solved it by uncheck "single instance only" check box in "run/debug configuration."

By the way each time I run Spring class (that have main method) new instance will be created.

The important point is never forget that we can't run application on same port. so it's necessary to set server.port = 0 in application.properties to run application on random port. enter image description here

Upvotes: 22

Denise Ignatova
Denise Ignatova

Reputation: 533

Click on 'Edit Configuration', when the pop-up appear. On the right hand side you wll see check boxes ,one of them says:'Allow run in parallel' - check this one.

Upvotes: 10

yole
yole

Reputation: 97138

You can copy the run configuration of your client, give it a different name and leave all other parameters unchanged. Then you'll be able to select the two copies in the "Compound" run configuration.

Upvotes: 39

Related Questions