This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set host in RMI

 
HiBob Chu
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition, I did above on Windows98.
 
HiBob Chu
Ranch Hand
Posts: 86
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2373
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic