I have create an application for our Costing department and also have created a separate application for our order entry department. Each application has it's own main method. What I am trying to do , is within the Costing application, I would like the user to be able to click on a button, and launch the order entry application. I tried just creating an object of the order entry class on an actionPerformed event in the costing app, but nothing came up. Is there something special I need to be doing? Here is the class with the main method in it for the order entry app...
You can do it 1 of 3 ways: 1. If you want the CVOrderEntry executing as a separate process (i.e. in a separate JVM), then use one of the java.lang.Runtime.exec() methods to kick off another process. 2. If you want them to execute in the same JVM, then as long as your other class has access to this CVOrderEntry object you can just call it directly. But, since you have some initialization stuff in your main(), you will have to do that as well in the calling class. 3. You could also use reflection and call the main() method in your CVOrderEntry class. Check out the java.lang.reflect package. Options 1 or 2 are the easiest.
The only thing to watch out for when calling the main method directly is what happens when the window closes. If both applications call System.exit(0) when their main window closes, then the User could start the first app, start the second window within the first app's process. The user finishes what he is doing in the second app and closes the window. This calls System.exit(0), which also then closes the first window! If this is the case, calling the Runtime.exec() methods is better -- just make sure that you capture the output (if there is any) from the called program.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.