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

How to start server at the port which not 1099?

 
shao zhimin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use java.rmi.registry.LocateRegistry.createRegistry(int port) method in my server, but if the port is not 1099, i start server to get following error:
java.rmi.ConnectException: Connection refused to host:172.16.2.44;nested exception is:
java.net.ConnectException: Connection refused: connect
if i use the port "1099" ,the error is not throw.
why??
 
Michael Morris
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Shao,
What port are you trying to use? Several things can cause a port connection to be refused. The most common two are:
1) Using a port number below 1024. Any port below 1024 requires super user or administrative access.
2) There is already a service bound to the port.
Hope this helps,
Michael Morris
 
shao zhimin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Michael for reply.
i check my code and find some error in
Naming.rebind(). my original code: Naming.rebind("Connection",connection); and modify:
Naming.rebind("//localhost ort/Connection",connection);
the program run well.
 
shao zhimin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another Question:
i have three package: client, server, OnlineHelp.
i have an JEditorPane code in my client package and user document in the OnlineHelp package.
How to get URL in my JEditorPane code??
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To get the URL for the html. You have to include the html file in the jar file and then use getClass().getResource("name of the html").
[ September 11, 2002: Message edited by: Samual Harvey ]
 
shao zhimin
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samual :
the JEditorPane code and the document must be in the same directory, is right?? If them pack the different directory, how to do it??
 
Samual Harvey
Ranch Hand
Posts: 119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by shao zhimin:
Samual :
the JEditorPane code and the document must be in the same directory, is right?? If them pack the different directory, how to do it??

No they can be in different directories. You should be able to access it. For testing create one html file inside your root directory and name it some weird name. Package the jar file and try this:-
URL url = this.getClass().getResource("weird.html");
If you move it in a directory then you need to chage the abv as getResource("dir/weird.html");

Easy way is two create you own html fiule in the root and put in the hyperlinks for the respective html files.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic