English 中文(简体)
马绍尔群岛共和国未支持的行动
原标题:the UnsupportedOperationException in RMI

I worked a simple program But when you run the client at the command This error appears

 HelloClient exception:  java.lang.UnsupportedOperationException: Not supported yet.

我的法典

实习班

    import java.rmi.*;

    public interface HelloInterface extends Remote { 

     public String say() throws RemoteException;


   }

执行班级

           import java.rmi.RemoteException;
           import java.rmi.server.UnicastRemoteObject;

         /** 
           *
           * @author x
           */
   public class HelloServerImpl extends UnicastRemoteObject implements HelloInterface {

   private String message; 

   public HelloServerImpl(String msg)throws RemoteException{
   message = msg;
   }


@Override
public String say() throws RemoteException {
    throw new UnsupportedOperationException("Not supported yet.");
}




 }

服务器班

     import java.rmi.Naming;

       /**
        *
        * @author x
        */
       public class HelloServer {
        public static void main (String []args ){
          try {
        Naming.rebind("HELLOSERVER", new HelloServerImpl("Hello word"));
        System.out.println("Hello Server is ready.");
    } catch (Exception ex) {
        System.out.println("Hello server failed: "+ ex);
    }


    }
    }

客户类别

          import java.rmi.Naming;

         /**
          *
          * @author x
          */
             public class HelloClient {
          public static void main(String[]args){

        HelloInterface hello;
        String url = "rmi://localhost/HELLOSERVER";


         try {
        hello = (HelloInterface)Naming.lookup(url);
        System.out.println(hello.say());
    } catch (Exception ex) {
       System.err.println("HelloClient exception:  " + ex);
    }

    }
   }

我准备写一下这些步骤,但还有同样的错误。

为什么?

最佳回答

你写了这封信:

@Override
public String say() throws RemoteException {
    throw new UnsupportedOperationException("Not supported yet.");
}

当然,它只是一个例外。 实际返回地体:

@Override
public String say() throws RemoteException {
    return "hello";
}
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签