This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Distributed Java and the fly likes how to set host in RMI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "how to set host in RMI" Watch "how to set host in RMI" New topic
Author

how to set host in RMI

HiBob Chu
Ranch Hand

Joined: Aug 12, 2002
Posts: 86
I run the example of RMI of JavaTutorial from
Sun website.
I placed the files as follows path:
f:\home\bob\src\engine\ComputeEngine.java
f:\home\stella\src\compute\Compute.java
f:\home\stella\src\compute\Task.java
I have made such changes:
host=>127.0.0.1
in both ComputeEngine.java and the command line:
"java - Djava.rmi.server.codebase=file:/f:\home\bob\public_html\classes/
-Djava.rmi.server.hostname=127.0.0.1
-Djava.security.policy=java.policy engine.ComputeEngine
". Also I did other needed work required by the example.
When I run it, such exception occured:
"Unkown host excetpion
...
"
How should I set all viralbles correctly?
Someone could give me a simple but complet example of using RMI step by stey? Thanks!
HiBob Chu
Ranch Hand

Joined: Aug 12, 2002
Posts: 86
In addition, I did above on Windows98.
HiBob Chu
Ranch Hand

Joined: Aug 12, 2002
Posts: 86
I have found the reason :
On Windows98, if you excute a command line use
a bat file, the exception occure, but if you excute the command directly instead of using a bat file, the excution go on correctly.
But there is still another problem about client:
I do the test on one machine. When I run the client , the following exception occured:
"Exception in thread "main" java.security.Access
ControlException: access denied(java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
at ...
at ...
...
at jdeveloper.rmi.HelloClient.main(HelloClient.java:11)
"
Someone could give me some advise?
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

AccessControlException are thrown when your systems' security manager (in our case, most probably an RMI security manager) uses the deafult restricted policy file that do no permit you to connect to your specified socket.
If you provide a policy file with access permissions granted or even if you simply don't mention any security manager in your code, your AccessControlException should not be seen.


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: how to set host in RMI
 
Similar Threads
RMI, dynamically load class into server, rmiregistry CLASSPATH
Compiling the example programme
RMI / connection refused
registry binding problem in RMI
RMI example code fails