0

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

Project Elements

3
  • 1
    I had a quick try, and had the correct message. Can you post the stack trace and the .project contents? I assume you are not using maven. Commented Oct 16, 2019 at 3:38
  • check stackoverflow.com/questions/36963248/… Commented Oct 16, 2019 at 6:53
  • I've added a screen shot that shows the project contents. The project just contains two Java classes and one interface. Also I'm wondering if Tomcat must be intalled in order to use Java RMI. Commented Oct 17, 2019 at 3:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.