The type java.rmi.RemoteException cannot be resolved. It is indirectly referenced from required .class files error in java

Shirish Herwade picture Shirish Herwade · Dec 5, 2012 · Viewed 11.6k times · Source

I'm really new to Java and trying to call web-service. I have taken a code from net

String message = "";
static Map output;

public static void main(String args[]) {
    try {
        String inputparam = "10000";

        Service service = new Service();
        Call call = (Call) service.createCall();

        call.setTargetEndpointAddress(new java.net.URL(""));
        call.setOperationName(new QName("http://testPackage.fc.com/, doBasicStuff"));

        call.addParameter("Hello", org.apache.axis.Constants.XSD_STRING, javax.xml.rpc.ParameterMode.IN);

        call.setReturnType(org.apache.axis.Constants.XSD_STRING);

        Object responseWS = call.invoke(new Object[] { inpurparam });

        System.out.println("ReceivingResponse: " + (String) responseWS);

        output = call.getOutputParams();

        String firstName = (String) output.get(new QName("", "firstName"));

    } catch (Exception e) {
        System.err.println(e.toString());
    }

}

which gives a syntax error

The type java.rmi.RemoteException cannot be resolved. It is indirectly referenced from required .class files

on the line

Object responseWS = call.invoke(new Object[] { inpurparam });

So I'm added "import java.rmi.RemoteException;" statement it gives error to the import statement "The import java.rmi.RemoteException cannot be resolved", so please tell how to remove this error

Answer

user513418 picture user513418 · Dec 5, 2012

You need to add

import java.rmi.RemoteException;

before your class declaration