質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Bluetooth

Bluetoothとは短距離の間でデータを交換するための無線通信規格である。固定・モバイル両方のデバイスから、短波の電波送信を行うことで、高いセキュリティをもつパーソナルエリアネットワーク(PAN)を構築する。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

Q&A

0回答

495閲覧

JavaでのBluetooth受信プログラムのエラーについて

ths

総合スコア21

Bluetooth

Bluetoothとは短距離の間でデータを交換するための無線通信規格である。固定・モバイル両方のデバイスから、短波の電波送信を行うことで、高いセキュリティをもつパーソナルエリアネットワーク(PAN)を構築する。

Java

Javaは、1995年にサン・マイクロシステムズが開発したプログラミング言語です。表記法はC言語に似ていますが、既存のプログラミング言語の短所を踏まえていちから設計されており、最初からオブジェクト指向性を備えてデザインされています。セキュリティ面が強力であることや、ネットワーク環境での利用に向いていることが特徴です。Javaで作られたソフトウェアは基本的にいかなるプラットフォームでも作動します。

0グッド

0クリップ

投稿2017/12/14 03:19

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); } }

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問