This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes ConnectionNotFoundException please help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "ConnectionNotFoundException please help" Watch "ConnectionNotFoundException please help" New topic

ConnectionNotFoundException please help

jawwad ahmed
Ranch Hand

Joined: Dec 01, 2001
Posts: 179
Well i was making the following program:
which is also in tutorial
public class FirstExample extends MIDlet {
private Display display;
String url = "";
public FirstExample() {
display = Display.getDisplay(this);
* This method is invoked when the MIDlet is activated
public void startApp() {
try {
} catch (IOException e) {
//Handle Exceptions any other way you like.
System.out.println("IOException " + e);
* Pause, discontinue....
public void pauseApp() { }
* Destroy cleans up everything.
public void destroyApp(boolean unconditional) { }
* read url via stream connection
void getViaStreamConnection(String url)
throws IOException {
StreamConnection c = null;
InputStream s = null;
StringBuffer b = new StringBuffer();
TextBox t = null;
try {
c = (StreamConnection);
s = c.openInputStream();
int ch;
while((ch = != -1) {
b.append((char) ch);
t = new TextBox("hello....",
b.toString(), 1024, 0);
} finally {
if(s != null) {
if(c != null) {
// display the contents of the file in a text box.
It gives follwing exceptions.While when i cal that t.txt file from IE5.0 It works but here it gives exception.Please Help. FirstExample.getViaStreamConnection(+30)at FirstExample.startApp(+8)at javax.microedition.midlet.MIDletProxy.startApp(+7)at com.sun.midp.midlet.Scheduler.schedule(+225)at com.sun.midp.Main.runLocalClass(+20)at com.sun.midp.Main.main(+68)Execution completed successfullyimport*;
Michael Yuan
Ranch Hand

Joined: Mar 07, 2002
Posts: 1427
Did you enable TCP/IP networking for your emulator and the OS running on your emulator?

Seam Framework:
jawwad ahmed
Ranch Hand

Joined: Dec 01, 2001
Posts: 179
Well i am using sun j2mewtlkit(motorola i85s).I can't find option where to enable tcp/ip.Can u please tell.
I agree. Here's the link:
subject: ConnectionNotFoundException please help
Similar Threads
Can Someone Help with Reading from a text file in J2ME
the problem abt communication between serlvet & midlet
the trouble of openInputStream()!
J2MEWTK 1.0.3 HTTP Connection