问题
Is it necessary or important to set a class path in the registry for RMI to work correctly?
回答1:
Contrary to @Rahul's baseless assertion, it is indeed necessary to set a CLASSPATH for the RMI Registry, unless:
- You are starting the Registry from a directory which is also the head of a package structure of .class files.
- You are using the codebase feature, or
- You are starting the Registry in the same JVM as your RMI remote obects, via
LocateRegistry.createRegistry().
If you don't do one of these four things, you will get a ServerException
wrapping a ClassNotFoundException
when you bind your remote object(s) to the Registry.
来源:https://stackoverflow.com/questions/20967220/is-it-necessary-important-to-set-a-classpath-in-the-rmi-registry