系统检查器在 MacOS Big Sur 上失败 "Java is not reachable"

System checker fails on MacOS Big Sur with "Java is not reachable"

我在 MacOS Big Sur 上 运行ning 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,它似乎试图 运行 under 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.access0(URLClassLoader.java:73)
    at java.net.URLClassLoader.run(URLClassLoader.java:368)
    at java.net.URLClassLoader.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 3.9.1 不会 运行 JDK 17。您需要将 JAVA_HOME 设置为指向您的 JDK 11 安装和其他 应该工作。

-- 滑板车