I have done mkdir to create coherent directory with packages example.hello and put in ~/example/hello the three .java files (Hello.java Server.java Client.java. Then i make the class files with a "javac example/hello/*.java" (I've done things up to here to both the server and the client machines)
Then i start the rmiregistry and launch "java example.hello.Server" on the first machine. It says: Server ready
When i start "java example.hello.Client 192.168.10.46" (that is the ip of the first machine) on the second machine i get these exceptions:
Client exception: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: java.net.ConnectException: Connection refused at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574) at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185) at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171) at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:94) at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:179) at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132) at $Proxy0.sayHello(Unknown Source) at example.hello.Client.main(Client.java:53) Caused by: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364) at java.net.Socket.connect(Socket.java:507) at java.net.Socket.connect(Socket.java:457) at java.net.Socket.<init>(Socket.java:365) at java.net.Socket.<init>(Socket.java:178) at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22) at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128) at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569) ... 7 more
Please help me to solve this problem!!! Thank you all.
That exceptions seems to say that your client is trying to connect to localhost, not the 192.168.10.46 address you specify. You should take another look at how the command line parameter is supposed to get used in the socket creation code.
Joined: Apr 21, 2006
Hi William,I think the problem is not there because i was trying to run a different program without commandline argument.i.e I was hardcoding the value..Do i have to change the java.policy in jre/lib/security....
Author and all-around good cowpoke
Joined: Mar 22, 2000
Look at that exception carefully. Try to imagine what the client trying to do that causes it. Try to figure out why the client is trying to do that.
Joined: Apr 21, 2006
I changed the ip in /etc/hosts and i am getting the results..