Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> 關於 Linux

CentOS 啟動 Eclipse 報錯 Failed to load the JNI shared library 解決辦法

編輯:關於 Linux

CentOS 上啟動 Eclipse 時彈出錯誤:
Failed to load the JNI shared library "/home/java2000_wl/jdk/jdk1.6.0_41/bin/../jre/lib/i386/client/libjvm.so"
主因是 SELinux 阻擋了 JVM 共享庫的載入。關閉 SELinux 即可解決。

解決步驟

  1. 編輯 SELinux 設定檔:
vi /etc/sysconfig/selinux
  1. 將 SELINUX=enforcing 改為 SELINUX=disabled:
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
  1. 重啟系統生效:
reboot

Eclipse JNI 錯誤截圖

原理說明

  • SELinux 在 Enforcing 模式下限制進程存取特定記憶體區域與共享庫,導致 Eclipse 找不到 libjvm.so。
  • 設為 disabled 後完全關閉 SELinux,JVM 可正常載入。
  • 若不想完全關閉,可嘗試 SELINUX=permissive(僅記錄不阻擋),但建議生產環境評估風險後再決定。

延伸:Ubuntu 下 Eclipse 無法啟動

Ubuntu 通常預設未啟用 SELinux,若遇同類錯誤,請檢查:

  • JDK/JRE 版本與 Eclipse 位數匹配(32/64 位)。
  • eclipse.ini 中 -vm 參數指向正確的 java 執行檔。
  • 安裝 openjdk-8-jdk 或 Oracle JDK 並設定 JAVA_HOME。
Copyright © Windows教程網 All Rights Reserved