java - How do I implement RMI using the computers connected in the same network? -


i tried implementing rmi concept using 2 computers connected in company network. binded remote object using ip address , specific port number. worked fine when tried in local machine.

now in order access other computer shared adder (extends remote ) interface .class file other computer , client code. when tried access it throwed classnotfoundexception: stub not found.

so shared stub.class file generated after running command >> rmic addimpl. after worked fine on remote computer also.

now question is, how rmi implemented ? need share both adder interface , stub class file generated in order client access our remote method ?

below classes , interfaces:

interface adder extends remote class addimpl extends unicastremoteobject implements adder class server class client 

you need share 3 files adder.class, adder.java, adderremote_stub.class (not java code)

let assume have compiled already

  1. create 2 different directories

  2. launch 3 command prompt

  3. set first 2 command prompt first directory (server)

    example: c:\rmiserver

    put files here

  4. set last 1 command prompt second directory (client)

    example: c:\rmiclient

    put client specific files, stub , remote here

  5. (optional) set classpath=. in command prompt

    this allow current directory files recognized in classpath

  6. important: run rmiregistry command within command prompt server .class files in classpath

    run rmiregistry 5000 command in of first 2 command prompt

    keep running

  7. run server "java myserver" in remaining command prompt of first 2

  8. run client "java myclient" in last command prompt different directory

    if is working network logic work

duplicate java.rmi.serverexception: remoteexception occurred in server thread (classnotfoundexception)


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -