1

ライブラリ smslib を Windows マシンにインストールしました。ライブラリのセットアップについては、Web サイト smslib.org のすべての指示に従いました。しかし、SendMessage の例を実行しようとすると、エラーが発生しました。

    package examples.modem;

    import org.smslib.AGateway;
    import org.smslib.IOutboundMessageNotification;
    import org.smslib.Library;
    import org.smslib.OutboundMessage;
    import org.smslib.Service;
    import org.smslib.modem.SerialModemGateway;

    public class SendMessage
    {
        public void doIt() throws Exception
        {

            OutboundNotification outboundNotification = new OutboundNotification();
            System.out.println("Example: Send message from a serial gsm modem.");
            System.out.println(Library.getLibraryDescription());
            System.out.println("Version: " + Library.getLibraryVersion());
            SerialModemGateway gateway = new SerialModemGateway("modem.com1", "COM12", 115200, "Huawei", "E303");
            gateway.setInbound(true);
            gateway.setOutbound(true);
            gateway.setSimPin("0000");
            // Explicit SMSC address set is required for some modems.
            // Below is for VODAFONE GREECE - be sure to set your own!
            gateway.setSmscNumber("+xxxxxxxxxxx");
            Service.getInstance().setOutboundMessageNotification(outboundNotification);
            Service.getInstance().addGateway(gateway);
            Service.getInstance().startService();
            System.out.println();
            System.out.println("Modem Information:");
            System.out.println("  Manufacturer: " + gateway.getManufacturer());
            System.out.println("  Model: " + gateway.getModel());
            System.out.println("  Serial No: " + gateway.getSerialNo());
            System.out.println("  SIM IMSI: " + gateway.getImsi());
            System.out.println("  Signal Level: " + gateway.getSignalLevel() + " dBm");
            System.out.println("  Battery Level: " + gateway.getBatteryLevel() + "%");
            System.out.println();
            // Send a message synchronously.
            OutboundMessage msg = new OutboundMessage("xxxxxxxxx", "Hello from SMSLib!");
            Service.getInstance().sendMessage(msg);
            System.out.println(msg);
            // Or, send out a WAP SI message.
            //OutboundWapSIMessage wapMsg = new OutboundWapSIMessage("xxxxxxxx",  new URL("http://www.smslib.org/"), "Visit SMSLib now!");
            //Service.getInstance().sendMessage(wapMsg);
            //System.out.println(wapMsg);
            // You can also queue some asynchronous messages to see how the callbacks
            // are called...
            //msg = new OutboundMessage("xxxxxxxxxxx", "Wrong number!");
            //srv.queueMessage(msg, gateway.getGatewayId());
            //msg = new OutboundMessage("308888888888", "Wrong number!");
            //srv.queueMessage(msg, gateway.getGatewayId());
            System.out.println("Now Sleeping - Hit <enter> to terminate.");
            System.in.read();
            Service.getInstance().stopService();
        }

          public class OutboundNotification implements IOutboundMessageNotification
    {
        public void process(AGateway gateway, OutboundMessage msg)
        {
            System.out.println("Outbound handler called from Gateway: " + gateway.getGatewayId());
            System.out.println(msg);
        }
    }

    public static void main(String args[])
    {
        SendMessage app = new SendMessage();
        try
        {
            app.doIt();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

エラー:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
The method getInstance() is undefined for the type Service
The method getInstance() is undefined for the type Service
The method getInstance() is undefined for the type Service
The method getInstance() is undefined for the type Service
The method getInstance() is undefined for the type Service

at examples.modem.SendMessage.doIt(SendMessage.java:34)
at examples.modem.SendMessage.main(SendMessage.java:79)

誰でもこれで私を助けてもらえますか?

4

1 に答える 1

0

チェックリスト:-

  • javax.comm.properties を追加し、
  • Win32.dll ファイル (これらはモデムと通信するために必要です)
  • smslib jar
  • 互換性のあるモデムがあることを確認してください。アンドロイドのスマホが動かない。内蔵モデムまたは usb-GSM モデムを備えた特定の古い学校のモデルが必要です。
  • パッケージに他のクラスはありますか?
于 2014-12-18T11:13:22.680 に答える