簡體   English   中英

無法解析java.rmi.RemoteException類型。 它是從java中所需的.class文件錯誤中間接引用的

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

我是Java新手,並試圖調用Web服務。 我從網上拿了代碼

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());
    }

}

這給出了語法錯誤

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

在線上

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

所以我添加了“import java.rmi.RemoteException;” 語句它給import語句錯誤“導入java.rmi.RemoteException無法解析”,所以請告訴我如何刪除此錯誤

你需要添加

import java.rmi.RemoteException;

在你的課堂宣言之前

java.rmi包是標准Java SE庫的一部分,因此默認情況下它們應該可用於所有Java代碼。 如果您的IDE找不到這些類,請檢查您的設置,項目構建路徑等,並確保它們是正確的,並且項目設置為使用Java SE運行時,而不是Android(它提供)一些java.*包但不是java.rmi )。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM