您的位置:首页 > 编程语言 > Java开发

Ubuntu下RMI Server 抛出java.rmi.ConnectException: Connection refused to host: 127.0.0.1解决办法

2011-07-05 23:29 567 查看
需要启动rmiregistry

参见
http://ubuntuforums.org/showthread.php?t=1278660
The actual reason is the rmiregistry service on your machine is not running......u hav two ways to solve it......

1) start terminal, type "rmiregistry" (without quotes) & hit enter. it will look like something has hanged up....but the service has been started........run your code now & things will work (only till the terminal looks in hanging state). closing the terminal or stopping the rmiregistry by ctrl+c will stop it.

2) second way is to add following snippet in your code -
static
{
try
{
LocateRegistry.createRegistry(1099);
}
catch (RemoteException e)
{
e.printStackTrace();
}
}

this will start the service till your code is running (on the default port 1099).
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐