【问题标题】:System checker fails on MacOS Big Sur with "Java is not reachable"MacOS Big Sur 上的系统检查器因“Java 无法访问”而失败
【发布时间】:2022-06-11 03:51:50
【问题描述】:

我在 MacOS Big Sur 上运行 Cytoscape 3.9.1 时遇到问题。系统检查程序失败并显示以下内容:

############# Cytoscape System Requirements Checker for Mac ##############
Target Cytoscape version: 3.9.0
Your shell is bash
Compatible OS version found: 11.6
 - Pass: OS Version = 11.6.1
 - Pass: Following Oracle JDK found:

/Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk
Fail: Java is not reachable.
Try re-installing Java 11.

我在输出中显示的位置安装了 Java 11,看起来还不错:

$ /Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home/bin/java -version
java version "11.0.5" 2019-10-15 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.5+10-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode)

权限看起来是正确的(这些权限在目录层次结构中一直是相同的):

$ ls -lh /Library/Java/JavaVirtualMachines/jdk-11.0.5.jdk/Contents/Home/bin/
total 6672
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jaotc
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jar
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jarsigner
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 java
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 javac
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 javadoc
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 javap
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jcmd
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jconsole
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jdb
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jdeprscan
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jdeps
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jhsdb
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jimage
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jinfo
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jjs
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jlink
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jmap
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jmod
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jps
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jrunscript
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jshell
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jstack
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jstat
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 jstatd
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 keytool
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 pack200
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 rmic
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 rmid
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 rmiregistry
-rwxr-xr-x  1 root  wheel   101K Oct  6  2019 serialver
-rwxr-xr-x  1 root  wheel   110K Oct  6  2019 unpack200

我还安装了几个最新的 Java 版本(我不确定这些是否会导致问题):

$ ls /Library/Java/JavaVirtualMachines/
jdk-10.0.2.jdk      jdk-12.0.2.jdk      jdk-14.0.1.jdk      jdk1.8.0_181.jdk
jdk-11.0.5.jdk      jdk-13.0.2.jdk      jdk-17.0.1.jdk

默认是JDK17:

$ java -version
java version "17.0.1" 2021-10-19 LTS
Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing)

如果我直接从命令行调用cytoscape.sh,它似乎试图在Java 8 下运行:

$ ./cytoscape.sh 
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/cytoscape/launcher/internal/Launcher has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

【问题讨论】:

    标签: cytoscape


    【解决方案1】:

    Cytoscape 3.9.1 将无法在 JDK 17 上运行。您需要将 JAVA_HOME 设置为指向您的 JDK 11 安装,应该工作。

    -- 滑板车

    【讨论】:

    • 谢谢:这行得通,但我能找到的唯一方法是从终端运行export JAVA_HOME=...; ./cytoscape.sh。这有点不方便,但可行。
    【解决方案2】:

    Java 也有类似的问题。因此,如果其他人有与我相同的问题,我将在此处包括我的答案。 首先我去这里查找“How to set or change the default Java (JDK) version on macOS?

    从那里您应该能够找到您想要使用的 Java 版本。然后设置你的 JAVA_HOME 变量

    使用 bash 或 zsh 你可以像这样设置你的 JAVA_HOME 环境变量:

    Bash 示例

    echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 11.0.7)" >> ~/.bash_profile

    或在 Zsh 中

    echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 11.0.7)" >> ~/.zshrc

    在此之后重新启动终端。

    您可以检查您的 shell 配置文件并看到此行现在已添加到配置文件的末尾: nano ~/.bash_profile

    export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home

    您现在还可以检查 java 是否默认映射到所需的 Java 版本: java -version

    在 mac 上运行系统检查器脚本现在应该可以识别 Java 已正确安装

    ./mac.sh

    现在应该通过单击 cytoscape.sh 脚本来运行 Cytoscape

    【讨论】:

      猜你喜欢
      • 2021-03-31
      • 2021-09-22
      • 2021-01-20
      • 2022-07-09
      • 2021-02-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-22
      相关资源
      最近更新 更多