I'm trying to do a simple client server program using Java RMI through Eclipse (version Helios Service Release 1). For the server side, I defined an interface, and a class that implements that interface. In the class I imported java.rmi., and java.rmi.server. API´s so here is where I have the error
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files
The version of my JRE is jre1.8.0_221
I tried to configure the build path by removing and adding the JRE System Library by default, cleaning the project, creating a new project. Basically, I`ve tried most of the options provided in stackOverflow for this kind of issue.
// The Interface
import java.rmi.*;
public interface HelloInterface extends Remote {
public String sayHello(String name) throws RemoteException;
}
// The class where I implement the interface
import java.rmi.*;
import java.rmi.server.*;
public class HelloImpl extends UnicastRemoteObject implements
HelloInterface {
private static final long serialVersionUID = 1L;
public HelloImpl() throws RemoteException {
super( );
}
public String sayHello(String name) throws RemoteException {
return "Hello, World!" + name;
}
}
// The main program
import java.rmi.*;
import java.rmi.registry.LocateRegistry;
public class HelloServer{
public static void main(String args[]){
try {
int port = 16790;
String host = "localhost";
HelloImpl exportedObj = new HelloImpl();
LocateRegistry.createRegistry(port);
String registryURL = "rmi://" + host + ":" + port + "/hello";
Naming.rebind(registryURL, exportedObj);
System.out.println("Hello Server ready.");
}catch (Exception e){
e.printStackTrace();
}
}
}
I expect the output Hello Server Ready
, but the program does not compile showing the error:
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files