Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7525467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T03:33:16+00:00 2026-05-30T03:33:16+00:00

everyone. I’m new here and this is my first post. I’m creating a simple

  • 0

everyone. I’m new here and this is my first post.
I’m creating a simple app that takes a content of the web. Below here is my code. The problem is, I cant get to run this on the simulator. No errors, no dialog boxes, just completely cannot be opened. If there’s anybody who can help me….

import java.io.InputStream;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
public class HTTPClient extends UiApplication {
LabelField test;

MainScreen screen = new MainScreen();

public static void main(String[] args)
{
HTTPClient theApp = new HTTPClient();
theApp.enterEventDispatcher();
}

public HTTPClient()
{
getPage("http://google.com");
}

public void getPage(String url) {
String response = "";
try {
StreamConnection s = (StreamConnection)Connector.open(url);
InputStream input = s.openInputStream();
byte[] data = new byte[256];
int len = 0;
StringBuffer raw = new StringBuffer();
while( -1 != (len = input.read(data))) {
raw.append(new String(data, 0, len));
}
response = raw.toString();
show(response);

input.close();
s.close();
} catch(Exception e) { }
}

public void show(String response) {
test = new LabelField(response);
screen.add(test);
pushScreen(screen);
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T03:33:17+00:00Added an answer on May 30, 2026 at 3:33 am

    Two notes regarding the code you posted:

    1. Networking operations (to be more precise, I would say that all non UI operations) should be done in a separate worker thread and not in the main event thread (UI thread in case of UIApplication).
    2. If you need access to the UI from outside the UI thread, then you can use the Application‘s invokeLater() or invokeAndWait() methods. Alternatively, a worker thread can synchronize on the event lock (returned by Application.getEventLock()) to ensure serialized access to the UI. Note that you should only hold this lock for short periods of time.

    As for the BlackBerry simulator and HTTP – In order to test a BlackBerry application that uses HTTP connection with the BlackBerry simulator, one must use the BlackBerry MDS (Mobile Data System) connection service. Here is a link to the relevant guide.

    Start the BlackBerry MDS Connection Service when you start the BlackBerry Smartphone Simulator

    1. In Eclipse®, on the Run menu, click Debug Configurations or Run Configurations.
    2. Expand the BlackBerry Simulator item.
    3. Complete one of the following tasks:
      • To work with an existing launch configuration, under BlackBerry Simulator, click a launch configuration.
      • To create a new launch configuration, right-click BlackBerry Simulator, select New.
    4. Click the Simulator tab.
    5. Click the General tab.
    6. Select the Launch Mobile Data System Connection Service (MDS-CS) with simulator check box.
    7. Click Apply.

    I also highly recommend to you to check the HTTPDemo sample that comes with the JREs you have downloaded (you have installed at least one JRE if you are able to compile your code). Here is guide on how to import these samples into Eclipse plugin.

    As for your code, I’ve modified it to meet the requirements I’ve mentioned:

    import java.io.InputStream;
    import javax.microedition.io.Connector;
    import javax.microedition.io.StreamConnection;
    import net.rim.device.api.ui.UiApplication;
    import net.rim.device.api.ui.component.LabelField;
    import net.rim.device.api.ui.container.MainScreen;
    
    public class HTTPClient extends UiApplication {
        private LabelField labelField;
    
        public static void main(String[] args) {
            HTTPClient theApp = new HTTPClient();
            theApp.enterEventDispatcher();
        }
    
        public HTTPClient() {
            MainScreen httpScreen = new MainScreen();
            labelField = new LabelField();
            httpScreen.add( labelField);
            pushScreen(httpScreen);
    
            new Thread() {
                public void run() {
                    getPage("http://google.com");
                }
            }.start();
        }
    
        public void getPage(String url) {
            try {
                StreamConnection s = (StreamConnection) Connector.open(url);
                InputStream input = s.openInputStream();
                byte[] data = new byte[256];
                int len = 0;
                StringBuffer raw = new StringBuffer();
                while (-1 != (len = input.read(data))) {
                    raw.append(new String(data, 0, len));
                }
                input.close();
                s.close();
    
                show(raw.toString());
    
            } catch (Exception e) {
            }
        }
    
        public void show(final String response) {
            Thread t = new Thread() {
                public void run() {
                    labelField.setText(response);
                }
            };
            UiApplication.getUiApplication().invokeLater(t);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

everyone. Here is a small VBA (Excel) function that i wrote, full of MsgBoxes
Everyone who's done any web application development in Scala knows that you can use
everyone. 1) I've always thought that if I leave my app through Home button
Everyone knows that this is not thread safe: public StringBuilder Builder { get {
everyone. I am new to PHP. I am having this problem with DateTime :
everyone, i have no idea why this doesn't work hopefully someone here can help
Everyone has this huge massively parallelized supercomputer on their desktop in the form of
Everyone managing open-source-software runs into the problem, that with the time the process of
Everyone is familiar with this functionality. If you open up the the outlook address
Everyone uses source-code control to manage versions (right?) and this provides some level of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.