1. 程式人生 > 其它 >java開發 Ubuntu下串列埠通訊 rxtx

java開發 Ubuntu下串列埠通訊 rxtx

依照教材,我直接在相關網站下載了RXTXcomm的相關包:Download - Rxtx (qbang.org)

 

在Ubuntu裡面,將 librxtxParallel.so  librxtxSerial.so 拷貝到jre資料夾下的 lib/amd64/裡面

然後拷貝 RXTXcomm.jar 到jre資料夾下的 lib//ext 裡面

 

寫程式碼:略(網上一抓一大把,有空補充,如果有人問的話)

 

執行jar包後報錯:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f84ae95e733
, pid=8075, tid=0x00007f84ae855700 # # JRE version: Java(TM) SE Runtime Environment (8.0_281-b09) (build 1.8.0_281-b09) # Java VM: Java HotSpot(TM) 64-Bit Server VM (25.281-b09 mixed mode linux-amd64 compressed oops) # Problematic frame: # C [librxtxSerial.so+0x7733] Java_gnu_io_RXTXPort_nativeDrain+0xc3 # # Failed to write core dump. Core dumps have been disabled. To enable core dumping,
try "ulimit -c unlimited" before starting Java again # # An error report file with more information is saved as: # /home/boocax/download/hs_err_pid8075.log # # If you would like to submit a bug report, please visit: # http://bugreport.java.com/bugreport/crash.jsp # The crash happened outside the Java Virtual Machine in
native code. # See problematic frame for where to report the bug. # 已放棄 (核心已轉儲)

解決辦法:

  sudo apt-get install librxtx-java 

 在: /urs/lib/jni/  資料夾中找到新的 lib,  librxtxParallel.so  和  librxtxSerial.so 拷貝到 jre資料夾下的 lib/amd64/ 裡面