1

这是我第一次使用 java rmic,所以我试图运行一个示例程序,但遇到了一个错误,这是我从中复制的代码:http: //learnersdashboard.blogspot.com/2015/07/rmi-addition-of- 2-numbers-example.html 现在显示以下错误:- 错误:./AdderRemote.class 中的类文件格式无效。major.minor 版本 '61.0' 太新了,这个工具无法理解。错误:找不到类 AdderRemote。2个错误 //远程接口导入java.rmi.*;

public interface Adder extends Remote{  
public int add(int x,int y)throws RemoteException;  
}  
//Implementation of remote interface
import java.rmi.*;  
import java.rmi.server.*;  
public class AdderRemote extends UnicastRemoteObject implements Adder{  
AdderRemote()throws RemoteException{  
super();  
}  
public int add(int x,int y){return x+y;}  
}  
//Server
import java.rmi.*;  
import java.rmi.registry.*;  
public class MyServer{  
public static void main(String args[]){  
try{  
Adder stub=new AdderRemote();  
Naming.rebind("rmi://localhost:5000/sonoo",stub);  
}catch(Exception e){System.out.println(e);}  
}  
}  
//Client Application
import java.rmi.*;  
public class MyClient{  
public static void main(String args[]){  
try{  
Adder stub=(Adder)Naming.lookup("rmi://localhost:5000/sonoo");  
System.out.println(stub.add(34,4));  
}catch(Exception e){}  
}  
}   

[error image][1]
4

0 回答 0