• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ConnectionNotFoundException please help

 
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well i was making the following program:
which is also in tutorial
public class FirstExample extends MIDlet {
private Display display;
String url = "http://127.0.0.1:8080/examples/t.txt";
public FirstExample() {
display = Display.getDisplay(this);
}
/**
* This method is invoked when the MIDlet is activated
*/
public void startApp() {
try {
getViaStreamConnection(url);
} catch (IOException e) {
//Handle Exceptions any other way you like.
System.out.println("IOException " + e);
e.printStackTrace();
}
}
/**
* 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)Connector.open(url);
s = c.openInputStream();
int ch;
while((ch = s.read()) != -1) {
b.append((char) ch);
}
System.out.println(b.toString());
t = new TextBox("hello....",
b.toString(), 1024, 0);
} finally {
if(s != null) {
s.close();
}
if(c != null) {
c.close();
}
}
// display the contents of the file in a text box.
display.setCurrent(t);
}
}
It gives follwing exceptions.While when i cal that t.txt file from IE5.0 It works but here it gives exception.Please Help.
javax.microedition.io.ConnectionNotFoundExceptionjavax.microedition.io.ConnectionNotFoundExceptionat com.sun.cldc.io.j2me.socket.Protocol.openPrim(+7)at com.sun.midp.io.InternalConnector.openPrim(+180)at com.sun.midp.io.InternalConnector.openInternal(+20)at com.sun.midp.io.j2me.http.StreamConnectionPool.createStreamConnectionElement(+140)at com.sun.midp.io.j2me.http.StreamConnectionPool.getConnection(+121)at com.sun.midp.io.j2me.http.Protocol.connect(+64)at com.sun.midp.io.j2me.http.Protocol.sendRequest(+90)at com.sun.midp.io.j2me.http.Protocol.openInputStream(+48)at 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.dev.DevMIDletSuiteImpl.schedule(+7)at com.sun.midp.Main.runLocalClass(+20)at com.sun.midp.Main.main(+68)Execution completed successfullyimport java.io.*;
 
author
Posts: 1436
6
Python TypeScript Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you enable TCP/IP networking for your emulator and the OS running on your emulator?
 
jawwad ahmed
Ranch Hand
Posts: 179
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well i am using sun j2mewtlkit(motorola i85s).I can't find option where to enable tcp/ip.Can u please tell.
Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic