Remote method invocation port in use

后端 未结 6 1064
不思量自难忘°
不思量自难忘° 2020-12-05 03:29

I have created a Server, Client kind of program with RMI. But whenever I run my Server after starting the rmiregistry from command prompt, the port already in use error is t

相关标签:
6条回答
  • 2020-12-05 03:47

    Use this Server code -

    Registry registry = null;
    try {
        registry = LocateRegistry.getRegistry(52365);//use any no. less than 55000
        registry.list();
        // This call will throw an exception if the registry does not already exist
    }
    catch (RemoteException e) { 
        registry = LocateRegistry.createRegistry(52365);
    }
    
    0 讨论(0)
  • 2020-12-05 03:51

    If you're using macOS, you can stop port following as:

    First thing you need to find the PID_number: lsof -i :1099

    And then kill that port: kill -9 PID_number

    0 讨论(0)
  • 2020-12-05 04:02

    Try this:

    lsof -P | grep ':1099' | awk '{print $2}' | xargs kill -9
    
    0 讨论(0)
  • 2020-12-05 04:09

    Re-check if the port 1099 is not used by any other process or user or start the rmiregistry on some other port.

    0 讨论(0)
  • 2020-12-05 04:10

    The rmiregistry is using port 1099 in its process so you can't use it in yours. Either:

    1. Start the registry in the same process, via LocateRegistry.createRegistry() (preferred).
    2. Export your object on a different port.
    3. Start the rmiregistry on a different port other than 1099.
    0 讨论(0)
  • 2020-12-05 04:10

    Use ps -aef |grep rmiregistry. find the pid which rmiregistry use. Kill the pid Den run the server again...!!!!

    0 讨论(0)
提交回复
热议问题