我使用smsj API從PC發送短信到手機通過GSM調制解調器。如在page上給出的,我已經嘗試了下面的代碼。發送短信從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的初學者。請幫助我的代碼。
note:我之前使用smslib api發送簡單的文本消息。但是這不支持ems消息。如果您有其他支持ems消息的庫,請告訴我。 smsj是我可以輕鬆下載的一個。
首先,你已經給了我們錯誤的代碼。類「SiemensOtaMessage」的代碼在哪裏?另外,請發佈完整的代碼堆棧跟蹤。 – 2013-03-07 07:16:13
@ Buhake Sindi我已經更新了這個問題 – newbee 2013-03-07 07:18:33
@BuhakeSindi它的第三部分代碼不是他的代碼。 – CloudyMarble 2013-03-07 07:18:39