This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I want to modify my code for more simple, I remember I have saw a post here before which said RMI could run without policy and codebase. I have tried it , but it doesn't work. Who can explain it clearly? Regards.
HiBob Chu
Ranch Hand
Joined: Aug 12, 2002
Posts: 86
posted
0
It didn't work just because I installed a new virson of JDK, and I have to modify it's java.policy again . now, it works. It's seem like that I have to provide a policy file. Because you shouldn't assume tester has the same policy file as yours. I still want to do something: move the policy file into jar file, how to do it? regards.
If you don't use security manager, you don't need policy file. Eugene.
HiBob Chu
Ranch Hand
Joined: Aug 12, 2002
Posts: 86
posted
0
hi Eugene: I have tried as you said. It does work, but I couldnt custom port number. Do I miss anything? regards.
John Smith
Ranch Hand
Joined: Oct 08, 2001
Posts: 2937
posted
0
You should have something like this in your code: LocateRegistry.createRegistry(port); ... registry = LocateRegistry.getRegistry(port); ... registry.rebind(SERVICE_NAME, remoteDataFactory); ... Eugene.
where in does this code chip into? i mean in which class do we write this, is it in the connection factory class, just before we do the lookup and rebind? thanks, sri
John Smith
Ranch Hand
Joined: Oct 08, 2001
Posts: 2937
posted
0
where in does this code chip into?
You do it before you do anything else, -- I have it in a class called StartServer. Eugene.
HiBob Chu
Ranch Hand
Joined: Aug 12, 2002
Posts: 86
posted
0
Hi Eugene: Thank you for your replays. And I use another way which can work too. ********************************** LocateRegistry.createRegistry(portNum); remoteDataFactory connect = new Server(); Naming.rebind("//:" + portNum + "/" + SERVER_NAME,connect); ********************************** Does it active as the same as yours?
Sri Addanki
Ranch Hand
Joined: Apr 27, 2001
Posts: 195
posted
0
Hi Eugene, Thanks. i'm starting registry in my code, like this. In my server class: java.rmi.registry.Registry registry = java.rmi.registry.LocateRegistry.createRegistry(1099); Naming.rebind ("rmi://localhost:1099/" + args[0], dataServer); and in my client class: java.rmi.registry.Registry registry = java.rmi.registry.LocateRegistry.getRegistry(); if(serverName.startsWith("rmi://localhost:1099/")) myServer_ = (RemoteIData)Naming.lookup(serverName); Is this ok? thanks, sri
Well it looks like your code in the client is assuming the server and client are running on the same machine. Actually your client doesn't need to find the registry, so to speak. The URL "rmi://host_name_or_ip" is what tells the client where to do the lookup. Mark
Actually your client doesn't need to find the registry, so to speak. Mark
Yes, Mark...thanks alot! i commented that line and compiled, it works fine. Yes , as you said the URL is just enough. Now i'll remove this getregistry line of code from my client. I wasn't sure why i was using that. thanks again, sri