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
create 2 different directories
launch 3 command prompt
set first 2 command prompt first directory (server)
example: c:\rmiserver
put files here
set last 1 command prompt second directory (client)
example: c:\rmiclient
put client specific files, stub , remote here
(optional) set classpath=. in command prompt
this allow current directory files recognized in classpath
important: run rmiregistry command within command prompt server .class files in classpath
run rmiregistry 5000 command in of first 2 command prompt
keep running
run server "java myserver" in remaining command prompt of first 2
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
Post a Comment