How to remotely shutdown a Java RMI Server

后端 未结 2 581
猫巷女王i
猫巷女王i 2021-02-15 16:39

I have a very simple Java RMI Server that looks like the following:

    import java.rmi.*;
    import java.rmi.server.*;

    public class CalculatorImpl extends         


        
2条回答
  •  难免孤独
    2021-02-15 17:03

    In case anyone is having a similar problem, I figured out the answer myself. Here is my exit() method:

    public void exit() throws RemoteException
    {
        try{
            // Unregister ourself
            Naming.unbind(mServerName);
    
            // Unexport; this will also remove us from the RMI runtime
            UnicastRemoteObject.unexportObject(this, true);
    
            System.out.println("CalculatorServer exiting.");
        }
        catch(Exception e){}
    }
    

提交回复
热议问题