java(PC)で文字列を受信するプログラムを作りたいと思い、PCのBluetoothをONにして指定した端末とペアリングしたうえで、実行したのですがこのようなエラーが出ました。解決方法を教えてください。BlueCoveのjarファイルはちゃんとインポートしました。
Exception in thread "main" javax.bluetooth.BluetoothStateException: BlueCove native library version mismatch at com.intel.bluetooth.BlueCoveImpl.detectStack(BlueCoveImpl.java:454) at com.intel.bluetooth.BlueCoveImpl.access$500(BlueCoveImpl.java:65) at com.intel.bluetooth.BlueCoveImpl$1.run(BlueCoveImpl.java:1020) at java.security.AccessController.doPrivileged(Native Method) at com.intel.bluetooth.BlueCoveImpl.detectStackPrivileged(BlueCoveImpl.java:1018) at com.intel.bluetooth.BlueCoveImpl.getBluetoothStack(BlueCoveImpl.java:1011) at com.intel.bluetooth.MicroeditionConnector.openImpl(MicroeditionConnector.java:196) at com.intel.bluetooth.MicroeditionConnector.open(MicroeditionConnector.java:525) at javax.microedition.io.Connector.open(Connector.java:113) at RecieveRequest.<init>(RecieveRequest.java:15) at RecieveRequest.main(RecieveRequest.java:64)
ソースコード(RecieveRequest.java)
import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; import java.util.Date; import javax.microedition.io.Connector; import javax.microedition.io.StreamConnection; import javax.microedition.io.StreamConnectionNotifier; public class RecieveRequest { static final String serverUUID = "0000110100001000800000805F9B34FB"; private StreamConnectionNotifier server = null; public RecieveRequest() throws IOException { server = (StreamConnectionNotifier) Connector.open("btspp://localhost:" + serverUUID,Connector.READ_WRITE, true); } //wait to connect from client public Session accept() throws IOException { log("Accept"); StreamConnection channel = server.acceptAndOpen(); log("Connect"); return new Session(channel); } //Session static class Session implements Runnable { private StreamConnection channel = null; private DataInputStream inputStream = null; private DataOutputStream outputStream = null; public Session(StreamConnection channel) throws IOException { this.channel = channel; this.inputStream = channel.openDataInputStream(); this.outputStream = channel.openDataOutputStream(); } @Override public void run(){ try { byte[] buf = new byte[2048]; int readByte = 0; while ((readByte = inputStream.read(buf)) > 0) { String cmd = new String(buf, 0, readByte); if(cmd == "Yes") System.out.println("Yes"); if(cmd == "No") System.out.println("No"); } } catch (Throwable t) { t.printStackTrace(); } finally { close(); } } public void close(){ log("Session Close"); if (inputStream != null) try {inputStream.close();} catch (Exception e) {/*ignore*/} if (outputStream != null) try {outputStream.close();} catch (Exception e) {/*ignore*/} if (channel != null) try {channel.close();} catch (Exception e) {/*ignore*/} } } //------------------------------------------------------ public static void main(String[] args) throws Exception { RecieveRequest server = new RecieveRequest(); while (true) { try { Session session = server.accept(); new Thread(session).start(); }catch (Exception e) { e.printStackTrace(); } } } private static void log(String msg) { System.out.println("["+(new Date()) + "] " + msg); } }
あなたの回答
tips
プレビュー