I am trying to run the sample RMI program at.


when i try to run the server i get the following error.

Exception occurred: java.rmi.RemoteException: access denied (java.net.SocketPerm
ission connect,resolve)

I suspect that the problem doe not lie in the code itself as the code was taken
verbatiom from the sun site.  I also get the same error when i run another borland example.  any ideas?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Did you setup a policy file as suggested at:


Look at the "note about security"... It provided a sample policy file for you to start with:


bchristieAuthor Commented:
Thanks s_franklin,

That seems to have solved part of the problem.  In the existing java.policy file commented out the old permission
and replaced it with the following.

      //permission java.net.SocketPermission "localhost:1024-", "listen";
        permission java.net.SocketPermission "*:1024-65535", "connect,accept,listen";
        permission java.net.SocketPermission "*:80", "connect";

I now get the error

java.rmi.ConnectException: Connection refused to host:

Are there other settings I need to change?

Hey that's a second question :)

Did you start your rmiregistry? That's a standard error you will get when you try to bind to the nameserver if it is not running. That's mentioned in the documents as the step you run prior to starting up the server - i.e. rmiregistry & if you're in a unix environment.

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Do you have a firewall or any other network restrictions that may be stopping the connection on this socket?

Network security often means that connections to some servers on sockets other than those specified by the firewall will not be allowed for instance.
Also, you will want to sure that you have your paths reconciled properly between your java.policy file (you have "*" so you should be okay there), the path specified for the String "name", i.e. "//your.machine.here/Compute", and the java.rmi.server.hostname define which you have specified when you start up your server. I have two shell scripts for starting up the server and client.

rmiregistry &
export CLASSPATH="c:/Demo;d:/Work/SearchWeb/classes/compute.jar"
//d/jdk1.2.2/bin/java \
-Djava.rmi.server.codebase=file:/d:/Work/HTML/classes/ \
-Djava.rmi.server.hostname=franklin \
-Djava.security.policy=java.policy engine.ComputeEngine

export CLASSPATH="c:/Demo;d:/Work/SearchWeb/HTML/classes/compute.jar"
//d/jdk1.2.2/bin/java \
-Djava.rmi.server.codebase=file:/d:/Work/SearchWeb/classes \
-Djava.security.policy=java.policy \
client.ComputePi localhost 20

I'm using cygwin (unix utilities port to Windows) so my paths look a bit funny (//d/path/here instead of /path/here or d:\path\here).


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bchristieAuthor Commented:
you caught me. that was in fact a second question.  your response was right on the money.

thanks for the help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.