Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Port already in use

 
Leandro Coutinho
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks! Happy New Year!!

I'm having problems with rmi. It doesn't matter which port I choose, I get Port already in use: 1212

Here's the code:

rmiregistry 1212 &
rmiregistry 1212 & java -cp classes -Djava.rmi.server.codebase=file:classes/ example.hello.Server
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default port for the RMI Registry is 1099. Just leave out the port number.
 
Leandro Coutinho
Ranch Hand
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Edward!

My mistake was on the second line. The correct command is:
java -classpath classDir -Djava.rmi.server.codebase=file:classDir/ example.hello.Server

The documentation says to use an & in the end of the command, but it works without it and I don't know its utility.

So I just executed this in one console: rmiregistry
And this in on the other console: java -classpath classDir -Djava.rmi.server.codebase=file:classDir/ example.hello.Server

Regards,
Leandro.
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to start a new process:
Windows is: start rmiregistry [optional port]
Unix is: rmiregistry [optional port] &

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic