Question

I'm looking for a communication channel between two java programs running on the same machine. I've found a few options (RMI and XML-RCP) but none of the examples that I found show exchange of objects wich class it's non-primitive and not know on JDK (our own objects).

So, what's the easy technology to use when I want to do this (note that Utils.jar it's on the classpath of Server.jar and Client.jar):

Utils.jar:

class MyClassRequestParams { ... }

class MyClassReturnParams { ... }

Client.jar:

// Server creation
...

// Send request
MyClassRequestParams params = new MyClass...

MyClassReturnParams response = server.send("serverMethodName", params);

Server.jar:

MyClassRequestParams serverMethodName(MyClassRequestParams params)
{
   MyClassReturnParams response = new MyC...

   // do processing

   return response;

}
Was it helpful?

Solution

Just make your transport classes implement the Serializable interface, and everything will be fine with RMI. Note that every object referenced bt the transport object should also be Serializable.

The RMI tutorial uses an example with a custom Task interface implemented by a Pi custom class that is not a "standard" JDK class.

OTHER TIPS

You may also consider Versile Java (I am one of its developers). Follow the link for an example of making remote calls and defining remote interfaces. It implements a platform-independent standard for remote ORB interaction, currently also available for python.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top