1

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

Shirish Herwade
  • 11,461
  • 20
  • 72
  • 111

2 Answers2

3

You need to add

import java.rmi.RemoteException;

before your class declaration

  • but when I add the above statement it gives error to the import statement "The import java.rmi.RemoteException cannot be resolved", so please tell how to remove this error – Shirish Herwade Dec 05 '12 at 11:38
  • You need to add the appropriate jar file to your classpath. –  Dec 05 '12 at 11:46
  • yes I know that, but for 1 hour now I'm searching that god damn jar, but no success, where to download that jar. I'm frustrated now, because for 1 hour I'm not able to download that jar. Can you please at-least tell me the name of the jar – Shirish Herwade Dec 05 '12 at 11:49
  • 1
    @WhyandHow `RemoteException` is part of the standard library of Java SE so it should always be available... You're not on Android, by any chance? If so [this question](http://stackoverflow.com/questions/5321906/how-to-find-the-jar-of-java-rmi-package) may help. – Ian Roberts Dec 05 '12 at 11:51
  • no I'm not on Android, I'm trying a Java project in eclipse, please tell me where to download that jar – Shirish Herwade Dec 05 '12 at 11:53
  • 2
    @WhyandHow if you're on Java SE then there is no JAR to download - it's part of the platform by default and has been since Java 1.1. – Ian Roberts Dec 05 '12 at 11:54
  • @WhyandHow which version of Java are you using? –  Dec 05 '12 at 11:57
  • I don't know how to check version, but I have folders named "jdk1.6.0_18" and "jre6" in my c:/Program Files/Java directory – Shirish Herwade Dec 05 '12 at 12:04
  • 2
    @WhyandHow in your Eclipse preferences, Java -> Installed JREs will tell you which Java runtimes Eclipse knows about. Then in your project's build path under Libraries there should be a "JRE System Library" listed. If there isn't, use the "add library" button to add one. – Ian Roberts Dec 05 '12 at 12:08
  • hey got the solution, my friend told me to add "jdk/jre/lib/rt.jar" as external jar in java build path, and it worked. thank God. I think, may be you were trying to say the same. By d ve, thanks a lot for your time and help – Shirish Herwade Dec 05 '12 at 12:12
1

The java.rmi packages are part of the standard Java SE library, so they should be available to all Java code by default. If your IDE can't find these classes, check your settings, project build path, etc. and make sure they are correct and that the project is set up to use a Java SE runtime as opposed to, for example, Android (which provides some java.* packages but not java.rmi).

Ian Roberts
  • 120,891
  • 16
  • 170
  • 183
  • hey got the solution, my friend told me to add "jdk/jre/lib/rt.jar" as external jar in java build path, and it worked. By the way, thanks – Shirish Herwade Dec 05 '12 at 12:17
  • 1
    @WhyandHow the fact that that is necessary means there is something wrong with the configuration of your JRE system libraries in Eclipse. I suggest you try and fix the cause of the problem (i.e. add a new JRE definition to your "Installed JREs" in Eclipse preferences) rather than just applying this workaround to fix the symptom. – Ian Roberts Dec 05 '12 at 12:22
  • yes, I also think that because when I was searching this error on net, no other in the world had that error before :) I will definitely do it when I get some free time – Shirish Herwade Dec 05 '12 at 13:10