Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to solve ConnectionNotFoundException in JavaME
    text
    copied!<p>I'm trying to connect to the internet via my J2ME application on my Netbeans emulator with the following function which connects to a webpage and prints out its HTML using <code>System.out.println()</code>.</p> <pre><code>function getHTML(String url) { HttpConnection httpConn = null; InputStream is = null; OutputStream os = null; try { httpConn = (HttpConnection)Connector.open(url); int respCode = httpConn.getResponseCode(); if (respCode == httpConn.HTTP_OK) { StringBuffer sb = new StringBuffer(); os = httpConn.openOutputStream(); is = httpConn.openDataInputStream(); int chr; while ((chr = is.read()) != -1) sb.append((char) chr); System.out.println(sb.toString()); os.close(); is.close(); } else { System.out.println("Error " + respCode); } httpConn.close(); } catch(IOException ioex) { ioex.printStackTrace(); } } </code></pre> <p>But I've been getting the following error;</p> <pre><code>javax.microedition.io.ConnectionNotFoundException: error 10051 in socket::open at com.sun.midp.io.j2me.socket.Protocol.open0(), bci=0 at com.sun.midp.io.j2me.socket.Protocol.connect(), bci=209 at com.sun.midp.io.j2me.socket.Protocol.open(), bci=216 at com.sun.midp.io.j2me.socket.Protocol.openPrim(), bci=4 at com.sun.midp.io.j2me.http.Protocol.createConnection(), bci=41 at com.sun.midp.io.j2me.http.Protocol.connect(), bci=41 at com.sun.midp.io.j2me.http.Protocol.streamConnect(), bci=164 at com.sun.midp.io.j2me.http.Protocol.startRequest(), bci=7 at com.sun.midp.io.j2me.http.Protocol.sendRequest(), bci=33 at com.sun.midp.io.j2me.http.Protocol.sendRequest(), bci=3 at com.sun.midp.io.j2me.http.Protocol.getResponseCode(), bci=5 </code></pre> <p>I know my code isn't the problem because this used to work on my old laptop, but it hasn't worked since I installed Netbeans on my new laptop. Is it because of my internet connection, or my firewall settings, or my settings in Netbeans, or did I just not install Netbeans properly?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload