Jkmn
Jkmn

Reputation: 571

Java - Running several main method

I have an eclipse project regrouping two applications, I want to run the second application by itself or from the first one, which I managed to do by simply calling the main method. The problem is that when I start that second app from the first, when I close that second application it also close the first application. Can I avoid that behavior and keep the first application running?

Thanks.

Upvotes: 3

Views: 403

Answers (1)

Perception
Perception

Reputation: 80603

Your second application is probably issuing a System.exit when closing. The only way of preventing this from dragging down the invoking application is to start it off in a separate process (via ProcessBuilder.start or Runtime.exec for instance), or by trapping and preventing the System.exit via means of a custom security manager.

Upvotes: 4

Related Questions