我對j2me波蘭語有疑問。我使用Eclipse的IDE。以下是我的J2ME文件:幫我解決j2me波蘭語 - 藍牙問題
BluetoothHandler.java
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的我的藍牙應用程序中的兩個Java文件。當我部署在移動和執行它工作正常(顯示設備地址和名稱被發現)。
但我創建了一個新的j2me波蘭項目。將這兩個java文件複製到j2me波蘭項目的源代碼目錄中。我還通過右鍵單擊在構建路徑中添加了「\ J2ME-Polish \ import \ btapi.jar」然後選擇properties-> java build path,然後選擇選項卡庫,然後添加btapi.jar。
然後我在Eclipse中運行與Wirless的工具包J2ME應用拋光的simulaotr.then以下錯誤arised
錯誤:
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幫我解決問題。
**感謝&問候,
爲什麼downvote?似乎他正確設置引用時遇到問題,這似乎是合法的。 –