java

位置:IT落伍者 >> java >> 浏览文章

java smslib发送短信


发布日期:2020年06月09日
 
java smslib发送短信

public class SendMessage {

public void doIt(String phone String content) throws IOException

InterruptedException SMSLibException {

Service srv;

OutboundMessage msg;

srv = new Service();

SerialModemGateway gateway = new SerialModemGateway(yUSB

/dev/ttyUSB WAVECOM MODEM W);//采用Sony Ericsson的Wc手机发送

gatewaysetProtocol(AGatewayProtocolsPDU);

gatewaysetInbound(true);

gatewaysetOutbound(true);

gatewaysetSimPin();

srvaddGateway(gateway);

srvstartService();

Systemoutprintln(Mobile Device Information: );

Systemoutprintln( Manufacturer : + gatewaygetManufacturer());

Systemoutprintln( Model : + gatewaygetModel());

Systemoutprintln( Serial No : + gatewaygetSerialNo());

Systemoutprintln( IMSI : + gatewaygetImsi());

Systemoutprintln( S/W Version : + gatewaygetSwVersion());

Systemoutprintln( Battery Level : + gatewaygetBatteryLevel() + %);

Systemoutprintln( Signal Level : + gatewaygetSignalLevel() + %);

msg = new OutboundMessage(phone content);

srvsendMessage(msg);

srvstopService();

}

public static void main(String args[]) throws IOException

InterruptedException SMSLibException {

SendMessage app = new SendMessage();

appdoIt(****** Hello);

}

}

运行: /usr/java/jre_/bin/java Dsmslibserialpolling classpath logjjar:smslibjar testSendMessage

出错: Exception in thread main javalangNoClassDefFoundDrror: SendMessage

后来终于找到原因: java加载了SendMessageclass以后java就试图到CLASSPATH中找类SendMessageCLASSPATH为

$CLASSPATH=/usr/java/jre_/lib:/usr/java/jre_/jre/lib

java找不到SendMessage类的定义windows包含了当前路径但是linux和unix没有当前路径必须手工添加

/usr/java/jre_/bin/java Dsmslibserialpolling classpath logjjar:smslibjar: testSendMessage

注意最后加了一个冒号和点冒号是linux下文件分割符

               

上一篇:怎样在Java实例开发的过程中使用进度条

下一篇:Java用于开发桌面应用的优劣分析