需要启动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).