Search code examples
javaregistryclasspathrmi

Is it necessary/important to set a classpath in the RMI registry?


Is it necessary or important to set a class path in the registry for RMI to work correctly?


Solution

  • Contrary to @Rahul's baseless assertion, it is indeed necessary to set a CLASSPATH for the RMI Registry, unless:

    1. You are starting the Registry from a directory which is also the head of a package structure of .class files.
    2. You are using the codebase feature, or
    3. 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.