我在我的 java 应用程序中使用SMSLib来发送SMS,我将USB 互联网调制解调器连接到我的 PC,然后确定它的端口号(即 COMx),然后创建一个像这样的串行调制解调器网关:
确定端口号:
创建网关:
SerialModemGateway gateway = new SerialModemGateway("mobile", "COM5", 115200, "Apple", "iPhone");
但无论我将端口定义为 COM4 还是 COM5,它首先运行连接,然后给我以下异常,然后以通常的方式停止服务:
0 2013-06-19 15:36:49,915 [main] INFO org.smslib.Service - SMSLib: A Java API library for sending and receiving SMS via a GSM modem or other supported gateways.
This software is distributed under the terms of the Apache v2.0 License.
Web Site: http://smslib.org
10 2013-06-19 15:36:49,925 [main] INFO org.smslib.Service - Version: 3.5.3
10 2013-06-19 15:36:49,925 [main] INFO org.smslib.Service - JRE Version: 1.7.0_21
经过大量运行和大量执行后:
org.smslib.GatewayException: Comm library exception: java.lang.RuntimeException: javax.comm.NoSuchPortException
at org.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:102)
at org.smslib.modem.AModemDriver.connect(AModemDriver.java:114)
at org.smslib.modem.ModemGateway.startGateway(ModemGateway.java:189)
at org.smslib.Service$1Starter.run(Service.java:277)
1463 2013-06-19 15:36:51,378 [NotifyQueueManager] DEBUG org.smslib.threading.AServiceThread - Running...
1463 2013-06-19 15:36:51,378 [NotifyQueueManager] DEBUG org.smslib.notify.NotifyQueueManager$NotificationQueueManager - NotifyQueueManager running...
1463 2013-06-19 15:36:51,378 [NotifyQueueManager] DEBUG org.smslib.threading.AServiceThread - Stopped.
值得一提的是,在执行期间和在抛出异常之前,它给了我这个错误:
Error loading win32com: java.lang.UnsatisfiedLinkError: no win32com in java.library.path
尽管我已经将 RxTx(64-bit) jar 文件添加到 jdk 并且应该避免SMSLib 文档中提到的那个错误。