背景:在win10x64,myEclipse軟件中移植他人的Java串口通信項目到自己電腦上時報錯
問題:在GUI界面上點擊“連接”按鈕,GUI界面閃退,並在myEclipse軟件console控制檯上報錯。
環境:windows10 x64系統 MyEclipse軟件
java配置信息:
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)
報錯信息如下:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0000000180004465, pid=25576, tid=30280
#
# JRE version: Java(TM) SE Runtime Environment (10.0.1+10) (build 10.0.1+10)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (10.0.1+10, mixed mode, tiered, compressed oops, g1 gc, windows-amd64)
# Problematic frame:
# C [rxtxSerial.dll+0x4465]
#
# No core dump will be written. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\...l\hs_err_pid25576.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 System Library一欄後面跟着的棕色字體顯示的內容(“Java JDK VM 1.10.0_Windows”)與報錯信息裏的“Java VM: Java HotSpot(TM) 64-Bit Server VM (10.0.1+10”不太同,猜想是被移植項目使用的jdk、jre跟本機的不同。所以搜索關鍵詞“java jdk vm 1.10”。
解決方法:
點擊MyEclipse上方工具欄Window-Preferences-Java-Installed JREs,添加本機的JRE,並將本機的JRE設爲默認。
詳細流程(帶圖)參考: