If you want to
exchange objects, you can open a ServerSocket on one machine, and connect to it through a Socket from the other. Then you can serialize objects over the connection.
If you want to invoke methods, RMI might be the way to go, although it does add some complexity.
If you don't mind considerable complexity, you can run an embedded
Tomcat with Axis, and make web service calls. But that sounds like overkill for what you describe.