问题描述
publicvoiddoIt()throwsException{Servicesrv;OutboundMessagemsg;OutboundNotificationoutboundNotification=newOutboundNotification();System.out.println("Example:Sendmessagefromaserialgsmmodem.");System.out.println(Library.getLibraryDescription());System.out.println("Version:"+Library.getLibraryVersion());srv=newService();//SerialModemGatewaygateway=newSerialModemGateway("modem.com3","COM3",9600,"wavecom","1111");SerialModemGatewaygateway=newSerialModemGateway("modem.com3","COM3",9600,"wavecom","1111");gateway.setInbound(true);gateway.setOutbound(true);gateway.setSimPin("0000");//gateway.setOutboundNotification(outboundNotification);//srv.setOutboundNotification(outboundNotification);srv.addGateway(gateway);srv.startService();System.out.println("ModemInformation:");System.out.println("ModemInformation:");System.out.println("Manufacturer:"+gateway.getManufacturer());System.out.println("Model:"+gateway.getModel());System.out.println("SerialNo:"+gateway.getSerialNo());System.out.println("SIMIMSI:"+gateway.getImsi());System.out.println("SignalLevel:"+gateway.getSignalLevel()+"%");System.out.println("BatteryLevel:"+gateway.getBatteryLevel()+"%");System.out.println();//Sendamessagesynchronously.msg=newOutboundMessage("13910740415","这个是用java发的中文短信!");//手机号码,和短信内容msg.setEncoding(MessageEncodings.ENCUCS2);//这句话是发中文短信必须的srv.sendMessage(msg);System.out.println(msg);System.out.println("NowSleeping-Hit<enter>toterminate.");System.in.read();srv.stopService();}
Eclipse里工程已经把smslib-3.4.1.jar加到工程里了,但是还是提示错误:Example:Sendmessagefromaserialgsmmodem.SMSLib:AJavaAPIlibraryforsendingandreceivingSMSviaaGSMmodemorothersupportedgateways.ThissoftwareisdistributedunderthetermsoftheApachev2.0License.WebSite:http://smslib.orgVersion:3.4.10[main]INFOsmslib-SMSLib:AJavaAPIlibraryforsendingandreceivingSMSviaaGSMmodemorothersupportedgateways.ThissoftwareisdistributedunderthetermsoftheApachev2.0License.WebSite:http://smslib.org0[main]INFOsmslib-Version:3.4.10[main]INFOsmslib-JREVersion:1.5.00[main]INFOsmslib-JREImplVersion:1.5.0-b640[main]INFOsmslib-O/S:WindowsXP/x86/5.131[Thread-0]INFOsmslib-GTW:modem.com3:Startinggateway,usingGenericATHandler.31[Thread-0]INFOsmslib-GTW:modem.com3:Opening:COM3@9600Exceptioninthread"Thread-0"java.lang.ExceptionInInitializerErroratorg.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:69)atorg.smslib.modem.AModemDriver.connect(AModemDriver.java:110)atorg.smslib.modem.ModemGateway.startGateway(ModemGateway.java:158)atorg.smslib.Service$1Starter.run(Service.java:239)Causedby:java.lang.RuntimeException:CommPortIdentifierclassnotfoundatorg.smslib.helper.CommPortIdentifier.<clinit>(CommPortIdentifier.java:76)...4more=========================================请教,谢谢
解决方案
解决方案二:
该回复于2009-07-14 09:15:19被版主删除
解决方案三:
没弄过,mark下
解决方案四:
我把comm.jart添加到Eclipse工程里了又出现了新的错误Example:Sendmessagefromaserialgsmmodem.SMSLib:AJavaAPIlibraryforsendingandreceivingSMSviaaGSMmodemorothersupportedgateways.ThissoftwareisdistributedunderthetermsoftheApachev2.0License.WebSite:http://smslib.orgVersion:3.4.10[main]INFOsmslib-SMSLib:AJavaAPIlibraryforsendingandreceivingSMSviaaGSMmodemorothersupportedgateways.ThissoftwareisdistributedunderthetermsoftheApachev2.0License.WebSite:http://smslib.org0[main]INFOsmslib-Version:3.4.10[main]INFOsmslib-JREVersion:1.5.00[main]INFOsmslib-JREImplVersion:1.5.0-b640[main]INFOsmslib-O/S:WindowsXP/x86/5.147[Thread-0]INFOsmslib-GTW:modem.com3:Startinggateway,usingGenericATHandler.47[Thread-0]INFOsmslib-GTW:modem.com3:Opening:COM3@9600org.smslib.GatewayException:Commlibraryexception:java.lang.RuntimeException:javax.comm.NoSuchPortExceptionatorg.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:99)atorg.smslib.modem.AModemDriver.connect(AModemDriver.java:110)atorg.smslib.modem.ModemGateway.startGateway(ModemGateway.java:158)atorg.smslib.Service$1Starter.run(Service.java:239)15062[pool-1-thread-1]WARNsmslib-WatchDog:Gateway:modem.com3restarting.15062[pool-1-thread-1]INFOsmslib-GTW:modem.com3:Stoppinggateway...15062[pool-1-thread-1]WARNsmslib-WatchDog:errorwhileshuttingdownGateway:modem.com3java.lang.NullPointerExceptionatorg.smslib.scheduler.Scheduler.remove(Scheduler.java:84)atorg.smslib.modem.AModemDriver.disconnect(AModemDriver.java:236)atorg.smslib.modem.ModemGateway.stopGateway(ModemGateway.java:169)atorg.smslib.Service$WatchDog.process(Service.java:1386)atorg.smslib.scheduler.ASchedulerTask.run(ASchedulerTask.java:80)atjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)atjava.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)atjava.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)atjava.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:65)atjava.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:142)atjava.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:166)atjava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)atjava.lang.Thread.run(Thread.java:595)15093[pool-1-thread-1]INFOsmslib-GTW:modem.com3:Startinggateway,usingGenericATHandler.15093[pool-1-thread-1]INFOsmslib-GTW:modem.com3:Opening:COM3@960015093[pool-1-thread-1]ERRORsmslib-WatchDog:errorwhilestartingGateway:modem.com3org.smslib.GatewayException:Commlibraryexception:java.lang.RuntimeException:javax.comm.NoSuchPortExceptionatorg.smslib.modem.SerialModemDriver.connectPort(SerialModemDriver.java:99)atorg.smslib.modem.AModemDriver.connect(AModemDriver.java:110)atorg.smslib.modem.ModemGateway.startGateway(ModemGateway.java:158)atorg.smslib.Service$WatchDog.process(Service.java:1395)atorg.smslib.scheduler.ASchedulerTask.run(ASchedulerTask.java:80)atjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:417)atjava.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:280)atjava.util.concurrent.FutureTask.runAndReset(FutureTask.java:135)atjava.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:65)atjava.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:142)atjava.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:166)atjava.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)atjava.lang.Thread.run(Thread.java:595)
解决方案五:
帮顶~!
解决方案六:
顶~Mark~
解决方案七:
我也准备写这样的东西呢帮顶学习学习
解决方案八:
javax.comm.NoSuchPortException你的短信设备是接到COM3上吗?
解决方案:
引用7楼9441的回复:
javax.comm.NoSuchPortException你的短信设备是接到COM3上吗?
是的
解决方案:
期待高手出现,能帮楼主解决难题!
解决方案:
看报错信息,楼主应该是环境没配置好吧。
解决方案:
配置没有配置好啊~~~和我昨天一样的错误~把javacomm20-win32包中的文件配置到<JDK_HOME>jrebinwin32com.dll<JDK_HOME>jrelibjavax.comm.properties<JDK_HOME>jrelibcomm.jarJAVA_HOME是jdk的路径,而非jre配置完后可以用下面的代码测试:成功则打印出端口名没成功什么都不打印publicstaticvoidmain(Stringargs[]){Enumerationen=CommPortIdentifier.getPortIdentifiers();CommPortIdentifierportId;while(en.hasMoreElements()){portId=(CommPortIdentifier)en.nextElement();if(portId.getPortType()==CommPortIdentifier.PORT_SERIAL){System.out.println(portId.getName());System.out.println("=============");}}}
解决方案:
原来是环境没配置好哦
解决方案:
学习 ..打算500强...中国移动行业!
解决方案:
该回复于2010-06-21 15:11:51被版主删除
解决方案:
学习一下啊!
解决方案:
看看。
解决方案:
有意思
解决方案:
一、配置Commlib:1.将win32com.dll放置在%JAVA_HOME%jrebin下2.将comm.jar放置在%JAVA_HOME%jrelibext下3.将javax.comm.properties放置在%JAVA_HOME%jarlib下二、将Eclipse中java/installedjres指定到和环境变量JAVA_HOME一样的路径,一般是JDK目录,而不是JRE目录。第二步往往容易忽略。
解决方案:
你的版本号有问题吧,用超级终端连上把要的参数重新确认一下