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 9054797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:46:39+00:00 2026-06-16T13:46:39+00:00

I am creating simple midlet for Bluetooth communication with server but I can’t get

  • 0

I am creating simple midlet for Bluetooth communication with server but I can’t get it to work on my phone, when I Try to run it in Eclipse/Emulator everything works fine, but on the phone I get “Cannot create MIDlet instance: java.lang.ClassNotFoundException”

I saw somewhere that this exception is mostly path related, but I don’t have any external jars or multiple packages.

Here is the code:

package j2meclient;

import java.io.OutputStream;
import javax.bluetooth.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class J2MEClientMidlet extends MIDlet implements CommandListener,
        Runnable {

    Display d;
    Command cmExit, cmConnect;
    Form f;
    Thread t;
    String connString;

    public J2MEClientMidlet() {
        f = new Form("Client");
        cmExit = new Command("Exit", Command.EXIT, 1);
        cmConnect = new Command("Connect", Command.ITEM, 2);

        f.addCommand(cmExit);
        f.addCommand(cmConnect);
        f.setCommandListener(this);
    }

    public void startApp() {
        if (d == null) {
            d = Display.getDisplay(this);
            d.setCurrent(f);
            t = new Thread(this);
        }
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void commandAction(Command c, Displayable d) {
        if (c == cmExit) {
            destroyApp(false);
            notifyDestroyed();
        }
        if (c == cmConnect) {
            t.start();
        }
    }

    public void run() {
        try {

            LocalDevice local = LocalDevice.getLocalDevice();
            DiscoveryAgent agent = local.getDiscoveryAgent();
            connString = agent.selectService(new UUID(
                    "86b4d249fb8844d6a756ec265dd1f6a3", false),
                    ServiceRecord.NOAUTHENTICATE_NOENCRYPT, false);
        } catch (Exception e) {
        }

        if (connString != null) {

            try {

                StreamConnection conn = (StreamConnection) Connector
                        .open(connString);
                OutputStream out = conn.openOutputStream();
                Thread.sleep(2000);

                out.write("Hello, World".getBytes());
                out.close();
                conn.close();
                f.append("Message sent correctly");

            } catch (Exception ex) {
                f.append("IOException: ");
                f.append(ex.getMessage());
            }
        } else {
            f.append("Unable to locate service");
        }
        }
    }

JAD;

MIDlet-1: J2MEClient,,J2MEClient
MIDlet-Jar-Size: 2254
MIDlet-Jar-URL: BTClient.jar
MIDlet-Name: BTClient Midlet Suite
MIDlet-Vendor: Midlet Suite Vendor
MIDlet-Version: 1.0.0
MicroEdition-Configuration: CLDC-1.1
MicroEdition-Profile: MIDP-2.0

Any ideas why I can’t run this on phone?

  • 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-06-16T13:46:41+00:00Added an answer on June 16, 2026 at 1:46 pm

    Your class file for the midlet is named J2MEClientMidlet but on the jad file it is defined as J2MEClient. Midlet class file name must match the definition on jad to run successfully from jad.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating a simple TCP server based on examples but still do not get how
I'm creating simple proxy server but I faced a strange situation, I've following code
Creating a simple RPG game, first time using XNA. Trying to get my character
I am creating simple application for Notification. It is showing notification properly But my
I am fairly familiar with creating simple custom controls, but I haven't had this
Im creating a simple WCF service for receiving crash reports. The service will run
I'm creating simple Socket server. Flex application will be client for this server. On
I'm creating simple image viewer, but I want to make a sorting of pictures
We are creating a simple but improved billing solution. Since we have to use
I'm creating simple peer to peer game. Currently I'm working on Server/Client(Node) side. I

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.