wts the "java.lang.ClassNotFoundException"???
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   umair_rahim
Posted On:   Sunday, November 21, 2004 11:06 AM

i m trying to access to a servlet runnig on the tomcat server on my own pc. my MIDlet compiles bt gives exception at thr run time... i am at u can say begginers level here is my full code...... if anyone of u can spare some time...i wld b thankfull import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.io.*; import java.util.*; import java.io.*; public class WelcomeMidlet extends MIDlet implements CommandListener { private Display display; private Form f1, f2, f3; private TextField tf1, tf2;    More>>

i m trying to access to a servlet runnig on the tomcat server on my own pc. my MIDlet compiles bt gives exception at thr run time... i am at u can say begginers level

here is my full code......


if anyone of u can spare some time...i wld b thankfull





import javax.microedition.midlet.*;


import javax.microedition.lcdui.*;


import javax.microedition.io.*;


import java.util.*;


import java.io.*;




public class WelcomeMidlet extends MIDlet implements CommandListener



{


private Display display;


private Form f1, f2, f3;


private TextField tf1, tf2;


private String url, name, serv;


private Alert a1, a2;


private Command exit, submit1, submit2, back1, back2;



public WelcomeMidlet()



{



display = Display.getDisplay(this);



a1 = new Alert("", " Connection Established!", null,


AlertType.INFO);


a2 = new Alert("", " Connection Failed to Establish!", null,
AlertType.INFO);



f1 = new Form("Connect to server");


tf1 = new TextField("Enter url:", "", 25, TextField.ANY);


exit = new Command("Exit", Command.EXIT, 1);


submit1 = new Command("Submit", Command.OK, 1);



f1.append(tf1);


f1.addCommand(exit);


f1.addCommand(submit1);



f1.setCommandListener(this);



f2 = new Form("Enter name");


tf2 = new TextField("Enter name:", "", 20, TextField.ANY);


back1 = new Command("Back", Command.BACK, 1);


submit2 = new Command("Submit", Command.OK, 1);



f2.append(tf2);


f2.addCommand(back1);


f2.addCommand(submit2);



f2.setCommandListener(this);



f3 = new Form("Enter name");



f3.setCommandListener(this);


}



public void startApp() throws MIDletStateChangeException {


display.setCurrent(f1);



}



public void pauseApp() {


}



public void destroyApp(boolean un) {


}



public void commandAction(Command c, Displayable displayable)

{


if (c == exit)

{


destroyApp(false);


notifyDestroyed();


}


else if (c == submit1) {


url = tf1.getString();



}



else if (c == back1) {


display.setCurrent(f1);


}



else if (c == submit2) {



name = tf2.getString();



serv = new String(url + "?" + "name=" + name);


conn(serv);



}


}


HttpConnection con1 = null;


InputStream in = null;


StringBuffer buffer = new StringBuffer();



public void conn(String serv) {



try {


con1 = (HttpConnection) Connector.open(serv);


display.setCurrent(a1);


display.setCurrent(f3);



in = con1.openInputStream();


int ch;


while ((ch = in.read()) != 1)



{


buffer.append((char) ch);


}


String line = new String(buffer.toString());


f3.append(line);



} catch (IOException e) {


a2.setTimeout(Alert.FOREVER);


display.setCurrent(a2);


}



}
}

   <<Less

RE: wts the "java.lang.ClassNotFoundException"???

Posted By:   Anonymous  
Posted On:   Monday, December 20, 2004 06:24 AM

hi there

i am new to the environment but i found the Solution to the problem.


Actually by default when we run javac command, it uses the classes in the jdk directory.

So to compile these programs of J2ME we have to set a bootclass path option with that javac command.


So the command goes like this

(the Format of the command)

javac target 1.1 -bootclasspath




even then the problem persist then u have to extract a zip file in to the lib directory of the j2me lib directory.


the file name is something like midap.zip or something like that.

this file actually contains the java lang package along with javax.microedition and lcdui and io packages


this should solve the problem


my name is anurag chaudhary

and i am an indian and the mailing address is anurag2k1@rediffmail.com





Thanks

Re: wts the "java.lang.ClassNotFoundException"???

Posted By:   Roseanne_Zhang  
Posted On:   Sunday, November 21, 2004 09:45 PM

Does HelloWorldMIDLet working?
About | Sitemap | Contact