我把程序都发上来大家帮偶看看到底是什么问题啊~~~晕了我.
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
//这个是显示j2me的display类
public class DisplayForm
extends Form
implements CommandListener,
Runnable
{
private TextField textField1;
private Thread t;
public DisplayForm()
{
super("字符转换webservice测试");
try
{
jbInit();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void jbInit()
throws Exception
{
// Set up this Displayable
textField1 = new TextField
("", "", 15, TextField.ANY);
this.setCommandListener(this);
textField1.setLabel
("待处理的字符串是:");
textField1.setConstraints
(TextField.ANY);
textField1.setInitialInputMode
("Tester");
setCommandListener(this);
// add the Exit command
addCommand(new Command
("Exit", Command.EXIT, 1));
addCommand(new Command
("Process", Command.OK, 1));
this.append(textField1);
}
public void commandAction
(Command command,
Displayable displayable)
{
if (command.getCommandType
() == Command.EXIT)
{
WSClientMIDlet.quitApp();
}
else if (command.getCommandType()
== Command.OK)
{
t = new Thread(this);
t.start();
}
}
public void run()
{
String s1 =
textField1.getString();
String s2 =
new StringProcessorStub().process(s1);
StringItem resultItem =
new StringItem("处理后的字符串是:", s2);
this.append(resultItem);
}
}
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class WSClientMIDlet
extends MIDlet
{
static WSClientMIDlet instance;
public WSClientMIDlet()
{
instance = this;
}
public void startApp()
{
Display display=
Display.getDisplay(this);
DisplayForm displayable =
new DisplayForm();
display.setCurrent(displayable);
}
public void pauseApp()
{
}
public void destroyApp
(boolean unconditional)
{
}
public static void quitApp()
{
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
}
就是这个类好象有问题大家帮我看看到底是什么原因啊谢谢 我用的是ksoap2+axis2+eclipse
import java.io.IOException;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import org.ksoap2.*;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;
import org.xmlpull.v1.XmlPullParserException;
import org.ksoap2.SoapEnvelope;
public class StringProcessorStub
{
public StringProcessorStub()
{
}
public String process(String name)
{
String result = null;
try{
SoapObject rpc =new SoapObject
("", "process");
rpc.addProperty("name", name);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.bodyOut = rpc;
HttpTransport ht = new HttpTransport("http://localhost:8080/axis2/services/MyServices");
ht.call("", envelope);
SoapObject ret = (SoapObject) envelope.bodyIn;
result = (String) ret.getProperty("processReturn");
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}
错误是Uncaught exception java/lang/NoClassDefFoundError: org/ksoap2/SoapEnvelope.
请问这个是为什么啊
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
//这个是显示j2me的display类
public class DisplayForm
extends Form
implements CommandListener,
Runnable
{
private TextField textField1;
private Thread t;
public DisplayForm()
{
super("字符转换webservice测试");
try
{
jbInit();
}
catch (Exception e)
{
e.printStackTrace();
}
}
private void jbInit()
throws Exception
{
// Set up this Displayable
textField1 = new TextField
("", "", 15, TextField.ANY);
this.setCommandListener(this);
textField1.setLabel
("待处理的字符串是:");
textField1.setConstraints
(TextField.ANY);
textField1.setInitialInputMode
("Tester");
setCommandListener(this);
// add the Exit command
addCommand(new Command
("Exit", Command.EXIT, 1));
addCommand(new Command
("Process", Command.OK, 1));
this.append(textField1);
}
public void commandAction
(Command command,
Displayable displayable)
{
if (command.getCommandType
() == Command.EXIT)
{
WSClientMIDlet.quitApp();
}
else if (command.getCommandType()
== Command.OK)
{
t = new Thread(this);
t.start();
}
}
public void run()
{
String s1 =
textField1.getString();
String s2 =
new StringProcessorStub().process(s1);
StringItem resultItem =
new StringItem("处理后的字符串是:", s2);
this.append(resultItem);
}
}
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class WSClientMIDlet
extends MIDlet
{
static WSClientMIDlet instance;
public WSClientMIDlet()
{
instance = this;
}
public void startApp()
{
Display display=
Display.getDisplay(this);
DisplayForm displayable =
new DisplayForm();
display.setCurrent(displayable);
}
public void pauseApp()
{
}
public void destroyApp
(boolean unconditional)
{
}
public static void quitApp()
{
instance.destroyApp(true);
instance.notifyDestroyed();
instance = null;
}
}
就是这个类好象有问题大家帮我看看到底是什么原因啊谢谢 我用的是ksoap2+axis2+eclipse
import java.io.IOException;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import org.ksoap2.*;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransport;
import org.xmlpull.v1.XmlPullParserException;
import org.ksoap2.SoapEnvelope;
public class StringProcessorStub
{
public StringProcessorStub()
{
}
public String process(String name)
{
String result = null;
try{
SoapObject rpc =new SoapObject
("", "process");
rpc.addProperty("name", name);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
envelope.bodyOut = rpc;
HttpTransport ht = new HttpTransport("http://localhost:8080/axis2/services/MyServices");
ht.call("", envelope);
SoapObject ret = (SoapObject) envelope.bodyIn;
result = (String) ret.getProperty("processReturn");
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return result;
}
}
错误是Uncaught exception java/lang/NoClassDefFoundError: org/ksoap2/SoapEnvelope.
请问这个是为什么啊