Share a free SMS cat java development kit and a free SMS development kit

Source: Internet
Author: User

Share a free SMS cat java development kit and a free SMS development kit

Professional industrial level SMS cat manufacturer, Shenzhen lianfa chuangke Technology Co., Ltd.

 

The procedure is as follows:
1. Put the smslib-3.3.0b2.jar, comm. jar and log4j-1.2.11.jar into the lib of the project;
2. Place javax. comm. properties under % JAVA_HOME %/jre/lib;
3. Put win32com. dll under % JAVA_HOME %/jre/bin;
4. Put comm. jar under % JAVA_HOME %/jre/ext.
Note: The Path is put wrong, the call will report an error; JDK version, with the version is the jdk-1_5_0_04.

After the configuration is completed, run the following code to send a message. The specific code is as follows:

Package com. alonely. notecat;
Import org. smslib. IOutboundMessageNotification;
Import org. smslib. Outbou, ndMessage;
Import org. smslib. Service;
Import org. smslib. Message. MessageEncodings;
Import org. smslib. modem. SerialModemGateway;

Public class SendMessage {
Public class OutboundNotification implements IOutboundMessageNotification {
Public void process (String gatewayId, OutboundMessage msg ){
System. out. println ("Outbound handler called from Gateway :"
+ GatewayId );
System. out. println (msg );
}
}
@ SuppressWarnings ("deprecation ")
Public void sendSMS (String mobilePhones, String content ){
Service srv;
OutboundMessage msg;
OutboundNotification outboundNotification = new OutboundNotification ();
Srv = new Service ();
SerialModemGateway gateway = new SerialModemGateway ("modem. com3 ",
"COM3", 9600, "wavecom", ""); // set the port and baud rate
Gateway. setInbound (true );
Gateway. setOutbound (true );
Gateway. setSimPin ("0000 ");
Gateway. setOutboundNotification (outboundNotification );
Srv. addGateway (gateway );
System. out. println ("initialization successful, ready to enable service ");
Try {
Srv. startService ();
System. out. println ("service started successfully ");
String [] phones = mobilePhones. split (",");
For (int I = 0; I <phones. length; I ++ ){
Msg = new OutboundMessage (phones [I], content );
Msg. setEncoding (MessageEncodings. ENCUCS2); // Chinese
Srv. sendMessage (msg );
}
Srv. stopService ();
} Catch (Exception e ){
E. printStackTrace ();
}
}
Public static void main (String [] args ){
SendMessage sendMessage = new SendMessage ();
SendMessage. sendSMS ("the mobile phone number you want to send", "the content you want to send! ");
}
}
After the code is pasted, the following describes the common problems encountered and how to solve them:
1. If the following error is reported: Exception in thread "main" java. lang. NoClassDefFoundError: org/apache/log4j/Logger
That's because I didn't pour the log4j-1.2.13.jar into the project.
2. If the following error is reported: org. smslib. GatewayException: Comm library exception: java. lang. RuntimeException: javax. comm. NoSuchPortException

Note that there is a problem with the JDK of your Eclipse choice, anyway, I am using the jdk-1_5_0_04 version, no problem; I have a problem with the JDK that comes with it under MyEclipse5.5, this please note.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.