1

I have two programs inside one of my eclipse project, one is the logic of the program, and another is the GUI. Both have their own main methods, and each of them execute as expected. Now, what I want to achieve is to run one program from another, i.e., when I press the button (from the GUI program), it should run the other program. How can I achieve this?

peterh
  • 11,875
  • 18
  • 85
  • 108
Robin
  • 5,366
  • 17
  • 57
  • 87

2 Answers2

0

Keep business logic and program execution separately. Have your logic in separate methods as services. From your GUI directly call the service methods, not the main method.

Don Srinath
  • 1,565
  • 1
  • 21
  • 32
0

You should use Runtime class and use its execute method to run another java class which contains main() method.But note that you are creating two JVM instances by doing this !

Ravi Jiyani
  • 919
  • 1
  • 10
  • 26
  • @Don : Agree with your point, but thats what he is asking for.Yes Its actually bad design, but though if he has such requirement he can do. – Ravi Jiyani Mar 11 '15 at 03:56