I want to share some information between two classes (A and B), which are running in different java programs. Instead of writing a whole communication protocol I want to use
How would class B know about class A without a second RMI server though? I think you are going to need two servers.
It's been a while since I've used RMI, but IIRC if class B implements java.rmi.Remote
and passes a reference to an instance of itself as a parameter to the method in class A, then class A should receive a stub and methods called on it will be called on the original instance.
However, if you have a lot of such RMI calls going back anf fro, you will probably encounter performance problems.