NoSuchPortException when running java application

2019-07-18 11:34发布

问题:

I'm using SMSLib in my java application to send an SMS, i connect a USB internet modem to my PC then determine it's port number (ie. COMx) then creating a serial modem gateway like this :

determining the port number :

creating the gateway:

SerialModemGateway gateway = new SerialModemGateway("mobile", "COM5", 115200, "Apple", "iPhone");

but whether i define the port as COM4 or as COM5 it runs the connection at first then gives me that following exception then stops the service by the usual way:

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

after a lot of running and a lot of executions:

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.

worth to mention that during the execution and before throwing the exception by while it gives me that error:

Error loading win32com: java.lang.UnsatisfiedLinkError: no win32com in java.library.path

despite i'm already adding the RxTx(64-bit) jar file to the jdk and that supposed to avoid that error as mentioned by the SMSLib documentation.

回答1:

get the modem port form , control panel > Phone and Modem > Modems now you can find the "attached To" COM port try with that