2011-08-12 8 views
0

私はj2meポリッシュの疑いがあった。私はEclipse IDEを使用しています。 J2MEの私のブルートゥース・アプリケーションの2つのJavaファイルがある上BluetoothHandler.javaj2meポリッシュを解決するのに役立ちます - ブルートゥースの問題

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.microedition.lcdui.Form; 

/** 
* @author sivakumar.j1 
* 
*/ 
public class BluetoothHandler implements DiscoveryListener { 

Form frm=null; 
LocalDevice localDevice=null; 
DiscoveryAgent agent=null; 
boolean inquiry_started=false; 
boolean bluetooth_turned_on=false; 

public BluetoothHandler(Form frm1) 
{ 
    frm=frm1; 
    frm1=null; 

} 

public void doDeviceSearching() 
{ 
    localDevice=null; 
    agent=null; 

    try 
    { 
    localDevice=LocalDevice.getLocalDevice(); 
    localDevice.setDiscoverable(DiscoveryAgent.GIAC); 
    bluetooth_turned_on=true; 
    } 
    catch(Exception ex) 
    { 
    ex.printStackTrace(); 
    frm.append("\n\tTurn on bluetooth in ur device"); 
    bluetooth_turned_on=false; 
    } 

    agent=localDevice.getDiscoveryAgent(); 
    inquiry_started=false; 

    if(this.bluetooth_turned_on) 
    { 
    try 
    { 
    inquiry_started=agent.startInquiry(DiscoveryAgent.GIAC,this); 
    if(inquiry_started==false) 
    frm.append("\n\tCannot able to start inquiry"); 
    else 
    frm.append("\n\tStarted inquiry"); 

    } 
    catch(Exception ex) 
    { 
    ex.printStackTrace(); 
    frm.append("\n\tInquiry starting exception : "+ex.toString()); 
    } 
    } 

} 
/* (non-Javadoc) 
    * @see javax.bluetooth.DiscoveryListener#deviceDiscovered(javax.bluetooth.RemoteDevice, javax.bluetooth.DeviceClass) 
    */ 
public void deviceDiscovered(RemoteDevice remoteDevice1, DeviceClass arg1) { 
    // TODO Auto-generated method stub 
    RemoteDevice remoteDevice=remoteDevice1; 
    String address=null; 
    String name=null; 
    try 
    { 
    address=remoteDevice.getBluetoothAddress(); 
    name=remoteDevice.getFriendlyName(true); 
    frm.append("\n\tDevice address : "+address+" , name : "+name); 
    address=name=null; 
    } 
    catch(Exception ex) 
    { 
    frm.append("\n\tException in getting name & address of device : "+ex.toString()); 
    } 

} 

/* (non-Javadoc) 
    * @see javax.bluetooth.DiscoveryListener#inquiryCompleted(int) 
    */ 
public void inquiryCompleted(int arg0) { 
    // TODO Auto-generated method stub 
    frm.append("\n\tInquiry completed"); 
} 

/* (non-Javadoc) 
    * @see javax.bluetooth.DiscoveryListener#serviceSearchCompleted(int, int) 
    */ 
public void serviceSearchCompleted(int arg0, int arg1) { 
    // TODO Auto-generated method stub 

} 

/* (non-Javadoc) 
    * @see javax.bluetooth.DiscoveryListener#servicesDiscovered(int, javax.bluetooth.ServiceRecord[]) 
    */ 
public void servicesDiscovered(int arg0, ServiceRecord[] arg1) { 
    // TODO Auto-generated method stub 

} 

} 

BluetoothMidlet.java

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.midlet.MIDlet; 
import javax.microedition.midlet.MIDletStateChangeException; 


public class BluetoothMidlet extends MIDlet implements CommandListener 
{ 

Form frm=null; 
Display display=null; 
Command cmdExit=null; 
Command cmdPair=null; 
BluetoothHandler handler=null; 

public BluetoothMidlet() { 
    // TODO Auto-generated constructor stub 

    display=Display.getDisplay(this); 
    frm=new Form("Tesing bluetooth"); 
    cmdExit=new Command("Exit",Command.EXIT,0); 
    cmdPair=new Command("Pair",Command.OK,1); 
    frm.append("\n\tTesting bluetooth"); 
    frm.addCommand(this.cmdExit); 
    frm.addCommand(this.cmdPair); 
    frm.setCommandListener(this); 

    display.setCurrent(frm); 
} 

protected void destroyApp(boolean flag) throws MIDletStateChangeException { 
    // TODO Auto-generated method stub 



    this.cmdExit=this.cmdPair=null; 
    this.frm=null; 
    this.display=null; 

    this.notifyDestroyed(); 
} 

protected void pauseApp() { 
    // TODO Auto-generated method stub 

} 

protected void startApp() throws MIDletStateChangeException { 
    // TODO Auto-generated method stub 

} 

public void commandAction(Command cmd, Displayable arg1) { 
    // TODO Auto-generated method stub 

    if(cmd==this.cmdExit) 
    { 
    try 
    { 
    this.destroyApp(true); 
    } 
    catch(Exception ex) 
    { 
    ex.printStackTrace(); 
    this.notifyDestroyed(); 
    } 
    } 
    else if(cmd==this.cmdPair) 
    { 
    handler=null; 
    this.handler=new BluetoothHandler(frm); 
    handler.doDeviceSearching(); 
    } 

} 

} 

ザ・

:次は私のJ2MEのファイルですモバイルにデプロイして実行すると正常に動作します(検出されたデバイスのアドレスと名前が表示されます)。

しかし、私は新しいJ2MEポリッシュプロジェクトを作成します.2つのJavaファイルをj2meポリッシュプロジェクトのソースディレクトリにコピーします。また、右クリックしてビルドパスに "\ J2ME-Polish \ import \ btapi.jar"を追加しますプロジェクトのプロパティ - > javaビルドパスを選択し、タブライブラリを選択してbtapi.jarを追加します。

次のエラーが

エラーarisedさsimulaotr.thenそれから私はwirlessツールキットと日食にJ2MEポリッシュアプ​​リケーションを実行します。

j2mepolish: 
[j2mepolish] info: the license attribute is no longer supported. Please place your license.key file either to ${project.home} or to ${polish.home}. 
[j2mepolish] J2ME Polish 2.0 (2008-02-10) (GPL License) 
[j2mepolish] Loading device database... 
[j2mepolish] using locale [de_DE]... 
[j2mepolish] assembling resources for device [Generic/DefaultColorPhone]. 
[j2mepolish] preprocessing for device [Generic/DefaultColorPhone]. 
[j2mepolish] Warning: CSS-Style [focused] not found, now using the default style instead. If you use Forms or Lists, you should define the style [focused]. 
[j2mepolish] Warning: CSS style [title] not found, you should define it for designing the titles of screens. 
[j2mepolish] processing locale code... 
[j2mepolish] compiling for device [Generic/DefaultColorPhone]. 
[j2mepolish-javac-Generic/DefaultColorPhone] Compiling 287 source files to C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\classes 
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:6: package javax.bluetooth does not exist 
    [javac] import javax.bluetooth.DeviceClass; 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:7: package javax.bluetooth does not exist 
    [javac] import javax.bluetooth.DiscoveryAgent; 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:8: package javax.bluetooth does not exist 
    [javac] import javax.bluetooth.DiscoveryListener; 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:9: package javax.bluetooth does not exist 
    [javac] import javax.bluetooth.LocalDevice; 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:10: package javax.bluetooth does not exist 
    [javac] import javax.bluetooth.RemoteDevice; 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:11: package javax.bluetooth does not exist 
    [javac] import javax.bluetooth.ServiceRecord; 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:18: cannot find symbol 
    [javac] symbol: class DiscoveryListener 
    [javac] public class BluetoothHandler implements DiscoveryListener { 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:21: cannot find symbol 
    [javac] symbol : class LocalDevice 
    [javac] location: class BluetoothHandler 
    [javac] LocalDevice localDevice=null; 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:22: cannot find symbol 
    [javac] symbol : class DiscoveryAgent 
    [javac] location: class BluetoothHandler 
    [javac] DiscoveryAgent agent=null; 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:76: cannot find symbol 
    [javac] symbol : class RemoteDevice 
    [javac] location: class BluetoothHandler 
    [javac] public void deviceDiscovered(RemoteDevice remoteDevice1, DeviceClass arg1) { 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:76: cannot find symbol 
    [javac] symbol : class DeviceClass 
    [javac] location: class BluetoothHandler 
    [javac] public void deviceDiscovered(RemoteDevice remoteDevice1, DeviceClass arg1) { 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:114: cannot find symbol 
    [javac] symbol : class ServiceRecord 
    [javac] location: class BluetoothHandler 
    [javac] public void servicesDiscovered(int arg0, ServiceRecord[] arg1) { 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:40: cannot find symbol 
    [javac] symbol : variable LocalDevice 
    [javac] location: class BluetoothHandler 
    [javac] localDevice=LocalDevice.getLocalDevice(); 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:41: cannot find symbol 
    [javac] symbol : variable DiscoveryAgent 
    [javac] location: class BluetoothHandler 
    [javac] localDevice.setDiscoverable(DiscoveryAgent.GIAC); 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:58: cannot find symbol 
    [javac] symbol : variable DiscoveryAgent 
    [javac] location: class BluetoothHandler 
    [javac] inquiry_started=agent.startInquiry(DiscoveryAgent.GIAC,this); 
    [javac]^
    [javac] Internal J2ME Polish class: C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real\Generic\DefaultColorPhone\de_DE\source\BluetoothHandler.java:78: cannot find symbol 
    [javac] symbol : class RemoteDevice 
    [javac] location: class BluetoothHandler 
    [javac] RemoteDevice remoteDevice=remoteDevice1; 
    [javac]^
    [javac] 16 errors 
    [javac] An internal class of J2ME Polish could not be compiled. Please try a clean rebuild by either calling "ant clean j2mepolish" or by removing the working directory "C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build\real". 
    [javac] When an API-class was not found, you might need to define where to find the device-APIs. Following classpath has been used: [C:\Users\sivakumar.j1\J2ME-Polish\import\mmapi.jar;C:\Users\sivakumar.j1\J2ME-Polish\import\midp-2.0.jar;C:\Users\sivakumar.j1\J2ME-Polish\import\cldc-1.1.jar;C:/Users/sivakumar.j1/J2ME-Polish/import/mmapi.jar;C:/Users/sivakumar.j1/J2ME-Polish/import/wmapi.jar;C:/Users/sivakumar.j1/J2ME-Polish/import/pdaapi.jar]. 

BUILD FAILED 
C:\Users\sivakumar.j1\j2me_polish_workspace\test_bluetooth1\build.xml:107: Unable to compile source code for device [Generic/DefaultColorPhone]: Compile failed; see the compiler error output for details. 

私は解決するために私を助けissues.Pleaseを解決することができないことができますが問題。

**おかげ&よろしく、

+0

なぜdownvoteですか?彼は正しく参照を設定するのに問題があるように思えますが、これは合法的です。 –

答えて

0

は、J2MEの研磨eclipse..If装置は、J2MEのBluetooth設定を有していないのデバイス選択手順から適切なデバイスを選択し、上記のエラーがそうaarie選択することができるpolish.The 「virtul default color phone」以外の適切なデバイス。

関連する問題