I'm writing an rmi application. Everything works perfectly fine when i put the all classes in one directory. However, when i try to split the server part and the client part, it raises java.lang.ClassNotFoundException.myclasses It seems to be the Registry can't find that class on its CLASSPATH. I'm wondering how to I solve this problem?
The registry is there to link up client interfaces with their server implementation classes. On the client, you will need to have the interface class definitions on the classpath.
Also, the client should not reference the implementation class at all - everything should be in the interface/stub class.
If this does not answer your question, you'll need to be more specific and provide at least some code.
Are you specifying the classpath directories in the arguments to both the client and server?
From the Tutorial:
Server
On the Solaris Operating System:
java -classpath classDir -Djava.rmi.server.codebase=file:classDir/ example.hello.Server &
On Windows platforms:
start java -classpath classDir -Djava.rmi.server.codebase=file:classDir/ example.hello.Server
Once the server is ready, the client can be run as follows:
java -classpath classDir example.hello.Client where classDir is the root directory of the class file tree
http://java.sun.com/javase/6/docs/technotes/guides/rmi/hello/hello-world.html#5