4 Replies Latest reply: Sep 24, 2010 9:15 AM by 843849 RSS

    (HttpConnection)Connector.open(url) returns NULL

      This has got to be something simple. I am trying to implement an HttpConnection on a Blackberry. Currently I am testing it in a Windows console app and the Connector.open() call always returns null:

      file: hc.java
      import java.io.*;
      import javax.microedition.io.*;
      public class hc {
          public hc() {
          public static void main(String[] args) {
              try {
              catch (Throwable t) {
          private static void getViaHttpConnection(String url) throws IOException {
              HttpConnection conn = null;
              InputStream is = null;
              int rc;
              conn = (HttpConnection)Connector.open(url);
              rc = conn.getResponseCode();
              if (rc != HttpConnection.HTTP_OK) {
                  throw new IOException("HTTP response code: " + rc);
      I execute this with:
      java -cp ".;/Program Files/Java/jdk1.6.0_21/lib;c;/Program Files/Java/Java_ME_platform_SDK_3.0/lib/cldc_1.1.jar;c;/Program Files/Java/Java_ME_platform_SDK_3.0/lib/midp_2.1.jar;/Program Files/Java/apache-log4j-1.2.16/log4j-1.2.16.jar" hc
      Result is always:
              at hc.getViaHttpConnection(Unknown Source)
              at hc.main(Unknown Source)
      Same result no matter what url I use. All I can figure is that I have a version mismatch in some of the libraries. Someone please help a newbie out!