I've got a design problem, and I am looking for possible solutions.
I have two Java programs running on one computer. I would like to keep the programs packaged separately, but I would like to call a few select methods of each program from the other. (Program #1 calls Mehtods A, B, and C from Program #2, while Program #2 calls methods D, E, and F from Program #1.)
I know there is an official Java package to communicate over a network, but that might be a little overkill, since both programs are running on the same computer. I don't think JINI would be appropriate either, because all my methods calls will be in Java. Niether would RMI be appropriate, because I'm using the same virtual machine. Any suggestions? Do I need something home grown here? This may be so simple that I'm just overlooking it.
If you are running 2 Java programs, then both of them are running in seperate instances of Java. In all practical aspects, both of them are running in differrent Virtual Machines, just as if they were running on seperate computers. All classes and variables will be loaded seperately
Your options in this case are a) RMI b) Sockets c) using shared Files/database to pass data- this option is messy, hence not reccomended
Why do you want your apps to talk to each other? Do you just want to reuse code, or do you really want to pass data between apps? If you just want to reuse code, I would suggest packaging your reusable classes in seperate jars, and using the jars in both apps
Thank you for your response. I want to transfer data and call mathods of both programs. In fact, I'd like to pass an object contained in one program as the argument to the method in the other program. I know I could facilitate this by parsing an XML file representing my request and the object, but ould RMI be the best?