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

Yenj_2302
  • 1
  • 1
  • 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. – boot-and-bonnet Oct 16 '19 at 03:38
  • check https://stackoverflow.com/questions/36963248/the-type-java-io-objectinputstream-cannot-be-resolved-it-is-indirectly-referenc – Devratna Oct 16 '19 at 06: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. – Yenj_2302 Oct 17 '19 at 03:02

0 Answers0