我正在使用 smsj api 通过 gsm 调制解调器将 sms 从 pc 发送到移动设备。如页面所示,我尝试了以下代码。
package org.marre;
import java.io.IOException;
import org.marre.sms.SmsException;
public class SendMessage {
public void send() {
try{
// Send SMS with clickatell
SmsSender smsSender = SmsSender.getGsmSender("COM7");
String msg ="sample message";
// International number to reciever without leading "+"
String reciever = "9561356345";
// Number of sender (not supported on all transports)
String sender ="9561356345";
// Connect
smsSender.connect();
// Send message
smsSender.sendTextSms(msg, reciever, sender);
// Disconnect
smsSender.disconnect();
} catch(IOException i){
i.printStackTrace();
System.out.println("i");
} catch(SmsException s){
s.printStackTrace();
System.out.println("s");
}
}
public static void main(String args[]){
SendMessage app = new SendMessage();
app.send();
}
}
但我收到此错误消息:
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
at org.marre.sms.transport.gsm.SerialComm.<clinit>(SerialComm.java:58)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.marre.sms.transport.gsm.GsmTransport.class$(GsmTransport.java:83)
at org.marre.sms.transport.gsm.GsmTransport.<clinit>(GsmTransport.java:83)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.marre.sms.transport.SmsTransportManager.getTransport(SmsTransportManager.java:75)
at org.marre.SmsSender.<init>(SmsSender.java:112)
at org.marre.SmsSender.getGsmSender(SmsSender.java:180)
at org.marre.SendMessage.send(SendMessage.java:12)
at org.marre.SendMessage.main(SendMessage.java:30)
Caused by: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 12 more
我是java的初学者。请帮我写代码。
注意: 我之前使用过 smslib api 来发送简单的短信。但这不支持 ems 消息。如果您有任何其他支持 EMS 消息的库,请告诉我。smsj 是我可以轻松下载的。