【Java读取串口】[rxtxSerial.dll+0x5b00]报错(使用RXTXcomm.dll)

发布时间 2023-05-24 17:03:53作者: zzsuje

使用RXTXcomm报错 EXCEPTION_ACCESS_VIOLATION (0xc0000005) C [rxtxSerial.dll+0x5b00]

原文链接:https://blog.csdn.net/Loveme_CN/article/details/115918493

1. 背景
项目中需要将信息通过串口方式发送至单片机,从而使用了RXTXxcomm这个工具包,本机已完成与串口工具的调试,在迁移至其他电脑中出现上述问题,找了网上许多的方法都没解决,特此记录。

2. 前期准备
串口虚拟工具(VSPD)下载地址

https://www.cr173.com/soft/21406.html

串口调试工具(Serial Port Utility)下载地址

https://www.jb51.net/softs/733127.html

3. 功能实现参考
前期主要参考,可实现主体功能:
https://blog.csdn.net/songyulong8888/article/details/78234275?utm_source=blogxgwz3

4. 迁移过程中问题
迁移过程中在本地可以实现与虚拟串口进行通信,但是迁移到测试机器上执行编译好的jar 包出现如下问题:

#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180005b00, pid=2468, tid=0x00000000000048bc 
#
# JRE version: Java(TM) SE Runtime Environment (8.0_261-b12) (build 1.8.0_261-b12)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.261-b12 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C [rxtxSerial.dll+0x5b00]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\Lenovo\Desktop\ChiswTest\hs_err_pid2468.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.

发现上述问题后,首先在网上试了好多帖子的方法,重配jre,安装新版jdk等,控制输出Buffer 都无济于事。

5. 解决办法
通过将jdk降版本至:jdk-8u231-windows-x64即可解决上述情况。

6.JDK下载
首先进入:https://www.oracle.com/downloads/ 选择Resource,进入该栏目下

进入页面后下拉至页面最底部,选择** Java Archive **进入历史版本

然后在后续页面选择Java SE 8 (8u211 and later) 后,选择具体版本下载即可。