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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:03:32+00:00 2026-05-13T16:03:32+00:00

i have the following code which is giving me error: /* * To change

  • 0

i have the following code which is giving me error:

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Vector;

import javax.bluetooth.BluetoothStateException;
import javax.bluetooth.DeviceClass;
import javax.bluetooth.DiscoveryAgent;
import javax.bluetooth.DiscoveryListener;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.RemoteDevice;
import javax.bluetooth.ServiceRecord;
import javax.bluetooth.UUID;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.List;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;


public class DeviceClientCOMM implements DiscoveryListener, CommandListener {

    static final boolean DEBUG = false;
    static final String DEBUG_address = "0013FDC157C8"; // N6630

    protected UUID uuid = new UUID(0x1101); // serial port profile

    protected int inquiryMode = DiscoveryAgent.GIAC; // no pairing is needed

    protected int connectionOptions = ServiceRecord.NOAUTHENTICATE_NOENCRYPT;

    protected int stopToken = 255;

    private Command backCommand = new Command("Back", Command.BACK, 1);
    protected Form infoArea = new Form("Bluetooth Client");
    protected Vector deviceList = new Vector();
  private CameraMIDlet mymidlet;
    private byte[] imag;

    public DeviceClientCOMM(CameraMIDlet m, byte[] imag) {
        mymidlet = m;
        this.imag = imag;
        infoArea.setCommandListener(this);
        infoArea.addCommand(backCommand);
        try {
            startApp();
        } catch (MIDletStateChangeException ex) {
            ex.printStackTrace();
        }
    }

    protected void startApp() throws MIDletStateChangeException {

        makeInformationAreaGUI();

        if (DEBUG) // skip inquiry in debug mode
        {
            startServiceSearch(new RemoteDevice(DEBUG_address) {
            });
        } else {
            try {
                startDeviceInquiry();
            } catch (Throwable t) {
                log(t);
            }
        }
    }

    private void startDeviceInquiry() {
        try {
            log("Start inquiry method - this will take few seconds...");
            DiscoveryAgent agent = getAgent();
            agent.startInquiry(inquiryMode, this);

        } catch (Exception e) {
            log(e);
        }
    }

    public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
        log("A device discovered (" + getDeviceStr(btDevice) + ")");
        deviceList.addElement(btDevice);
    }

    public void inquiryCompleted(int discType) {
        log("Inquiry compeleted. Please select device from combo box.");
        makeDeviceSelectionGUI();
    }

    private void startServiceSearch(RemoteDevice device) {
        try {
            log("Start search for Serial Port Profile service from " + getDeviceStr(device));
            UUID uuids[] = new UUID[]{uuid};
            getAgent().searchServices(null, uuids, device, this);
        } catch (Exception e) {
            log(e);
        }
    }

    public void servicesDiscovered(int transId, ServiceRecord[] records) {
        log("Service discovered.");
        for (int i = 0; i < records.length; i++) {
            ServiceRecord rec = records[i];
            String url = rec.getConnectionURL(connectionOptions, false);
            handleConnection(url);
        }
    }

    public void serviceSearchCompleted(int transID, int respCode) {
        String msg = null;
        switch (respCode) {
            case SERVICE_SEARCH_COMPLETED:
                msg = "the service search completed normally";
                break;
            case SERVICE_SEARCH_TERMINATED:
                msg = "the service search request was cancelled by a call to DiscoveryAgent.cancelServiceSearch()";
                break;
            case SERVICE_SEARCH_ERROR:
                msg = "an error occurred while processing the request";
                break;
            case SERVICE_SEARCH_NO_RECORDS:
                msg = "no records were found during the service search";
                break;
            case SERVICE_SEARCH_DEVICE_NOT_REACHABLE:
                msg = "the device specified in the search request could not be reached or the local device could not establish a connection to the remote device";
                break;
        }
        log("Service search completed - " + msg);
    }

    private void handleConnection(final String url) {
        Thread echo = new Thread() {

            public void run() {
                StreamConnection stream = null;
                InputStream in = null;
                OutputStream out = null;

                try {
                    log("Connecting to server by url: " + url);
                    stream = (StreamConnection) Connector.open(url);

                    log("Bluetooth stream open.");
                    //   InputStream in = stream.openInputStream();
                    out = stream.openOutputStream();
                    in = stream.openInputStream();
                    startReadThread(in);
                    // String stringImage = Base64.encode(imag);
                    log("Start echo loop.");
                    out.write(imag);
                    out.flush();
                //       out.flush();

                //   stream.close();

                } catch (IOException e) {
                    log(e);
                } finally {
                    log("Bluetooth stream closed.");
                    if (out != null) {
                        try {

                            out.close();
                            stream.close();

                            logSet("Image Transfer done\n----------------\n\nWaiting for results...");
                        } catch (IOException e) {
                            log(e);
                        }
                    }
                }
            }
        };
        echo.start();
    }

    private void startReadThread(final InputStream in) {

        Thread reader = new Thread() {

            public void run() {

                byte[] s = new byte[512];
                //boolean flag = true;
                try {
                    while (true) {
                        int r = in.read(s);

                        if (r != -1) {

                            logSet(new String(s, 0, r));
                        }  else {
                            break;
                        }


                        Thread.sleep(200);
                    }
                } catch (Throwable e) {
                    log(e);

                } finally {
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                        }
                    }
                }
            }
        };
        reader.start();
    }

    private void makeInformationAreaGUI() {
        infoArea.deleteAll();
        Display.getDisplay(mymidlet).setCurrent(infoArea);
    }

    private void makeDeviceSelectionGUI() {
        final List devices = new List("Select a device", List.IMPLICIT);
        for (int i = 0; i < deviceList.size(); i++) {
            devices.append(
                    getDeviceStr((RemoteDevice) deviceList.elementAt(i)), null);
        }
        devices.setCommandListener(new

              CommandListener(   ) {

    public  void commandAction(Command arg0,
        Displayable arg1)
        {
                makeInformationAreaGUI();
                startServiceSearch((RemoteDevice) deviceList.elementAt(devices.getSelectedIndex()));
            }
        });
        Display.getDisplay(mymidlet).setCurrent(devices);
    }

    synchronized private void log(String msg) {
        infoArea.append(msg);
        infoArea.append("\n\n");
    }

    synchronized private void logSet(String msg) {
        infoArea.deleteAll();
        infoArea.append(msg);
        infoArea.append("\n\n");

    }

    private void log(Throwable e) {
        log(e.getMessage());
    }

    private DiscoveryAgent getAgent() {
        try {
            return LocalDevice.getLocalDevice().getDiscoveryAgent();
        } catch (BluetoothStateException e) {
            throw new Error(e.getMessage());
        }
    }

    private String getDeviceStr(RemoteDevice btDevice) {
        return getFriendlyName(btDevice) + " - 0x" + btDevice.getBluetoothAddress();
    }

    private String getFriendlyName(RemoteDevice btDevice) {
        try {
            return btDevice.getFriendlyName(false);
        } catch (IOException e) {
            return "no name available";
        }
    }

    public void commandAction(Command arg0, Displayable arg1) {
        mymidlet.DisplayMainList();
    }
}

the errors are

C:\Documents and Settings\admin\My Documents\NetBeansProjects\DeviceClientCOMM\src\DeviceClientCOMM.java:51: cannot find symbol

symbol : class CameraMIDlet

location: class DeviceClientCOMM
private CameraMIDlet mymidlet;

C:\Documents and Settings\admin\My Documents\NetBeansProjects\DeviceClientCOMM\src\DeviceClientCOMM.java:54: cannot find symbol

symbol : class CameraMIDlet

location: class DeviceClientCOMM
public DeviceClientCOMM(CameraMIDlet m, byte[] imag)

  • 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-13T16:03:32+00:00Added an answer on May 13, 2026 at 4:03 pm

    You don’t have an import for CameraMIDlet, so the compiler doesn’t know which class you mean.

    Assuming you’ve got an appropriate classpath entry, you should just be able to add the right import and it should be fine.

    Are you sure CameraMIDlet exists for your use though? I can see some sample code in JSR-135, but I’m not sure it’s a full API to be used…

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

Sidebar

Ask A Question

Stats

  • Questions 375k
  • Answers 375k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I cant see where you initialise private XmlAttributeCollection _attr; you… May 14, 2026 at 8:23 pm
  • Editorial Team
    Editorial Team added an answer how can I configure hbm2cfgxml so that hibernate.cfg.xml looks like… May 14, 2026 at 8:23 pm
  • Editorial Team
    Editorial Team added an answer You can like: window.open('url', 'window name', 'window settings') jQuery: $('a#link_id').click(function(){… May 14, 2026 at 8:23 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.