我下载了一个 jdk7 tarball,用于在升级期间测试与一些旧软件的兼容性。当我解压它时,我当然得到了一堆被隔离的文件。在找不到从解压目录中的符号链接中删除隔离标志的方法后,我终于聪明了,取消了包本身的隔离,删除了所有内容并重新提取了 tarball。
NS2-MacBook-Pro:tools gus$ sudo xattr -d com.apple.quarantine /Users/gus/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64.tar.gz
NS2-MacBook-Pro:tools gus$ rm -rf zulu7.40.0.15-ca-jdk7.0.272-macosx_x64
NS2-MacBook-Pro:tools gus$ tar xzvf zulu7.40.0.15-ca-jdk7.0.272-macosx_x64.tar.gz
NS2-MacBook-Pro:tools gus$ ls -al@ ~/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64/
total 0
drwxr-xr-x 19 gus staff 608 Jul 7 11:27 .
drwxr-xr-x 43 gus staff 1376 Oct 14 20:03 ..
lrwxr-xr-x 1 gus staff 43 Jul 9 22:27 ASSEMBLY_EXCEPTION -> zulu-7.jdk/Contents/Home/ASSEMBLY_EXCEPTION
lrwxr-xr-x 1 gus staff 49 Jul 9 22:27 CLASSPATH_EXCEPTION_NOTE -> zulu-7.jdk/Contents/Home/CLASSPATH_EXCEPTION_NOTE
lrwxr-xr-x 1 gus staff 35 Jul 9 22:27 DISCLAIMER -> zulu-7.jdk/Contents/Home/DISCLAIMER
lrwxr-xr-x 1 gus staff 32 Jul 9 22:27 LICENSE -> zulu-7.jdk/Contents/Home/LICENSE
lrwxr-xr-x 1 gus staff 43 Jul 9 22:27 THIRD_PARTY_README -> zulu-7.jdk/Contents/Home/THIRD_PARTY_README
lrwxr-xr-x 1 gus staff 37 Jul 9 22:27 Welcome.html -> zulu-7.jdk/Contents/Home/Welcome.html
lrwxr-xr-x 1 gus staff 28 Jul 9 22:27 bin -> zulu-7.jdk/Contents/Home/bin
lrwxr-xr-x 1 gus staff 29 Jul 9 22:27 demo -> zulu-7.jdk/Contents/Home/demo
lrwxr-xr-x 1 gus staff 32 Jul 9 22:27 include -> zulu-7.jdk/Contents/Home/include
lrwxr-xr-x 1 gus staff 28 Jul 9 22:27 jre -> zulu-7.jdk/Contents/Home/jre
lrwxr-xr-x 1 gus staff 28 Jul 9 22:27 lib -> zulu-7.jdk/Contents/Home/lib
lrwxr-xr-x 1 gus staff 28 Jul 9 22:27 man -> zulu-7.jdk/Contents/Home/man
lrwxr-xr-x 1 gus staff 35 Jul 9 22:27 readme.txt -> zulu-7.jdk/Contents/Home/readme.txt
lrwxr-xr-x 1 gus staff 32 Jul 9 22:27 release -> zulu-7.jdk/Contents/Home/release
lrwxr-xr-x 1 gus staff 31 Jul 9 22:27 sample -> zulu-7.jdk/Contents/Home/sample
lrwxr-xr-x 1 gus staff 32 Jul 9 22:27 src.zip -> zulu-7.jdk/Contents/Home/src.zip
drwxr-xr-x 3 gus staff 96 Jul 7 11:27 zulu-7.jdk
NS2-MacBook-Pro:tools gus$ ls -al@ ~/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64/bin/java
-rwxr-xr-x 1 gus staff 110880 Jul 9 22:27 /Users/gus/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64/bin/java
这似乎是成功的,因为我现在能够从我的终端命令行运行解压目录中的 java 命令,
NS2-MacBook-Pro:tools gus$ ~/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64/bin/java
Usage: java [-options] class [args...]
(to execute a class)
... etc ...
这对于用反引号括起来或者$()
也行得通,但是……但是 ant build(或任何 bash 调用)似乎仍然无法运行它。
NS2-MacBook-Pro:tools gus$ bash ~/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64/bin/java
/Users/gus/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64/bin/java: /Users/gus/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64/bin/java: cannot execute binary file
or
NS2-MacBook-Pro:tools gus$ ant
Error: JAVA_HOME is not defined correctly.
We cannot execute ~/tools/zulu7.40.0.15-ca-jdk7.0.272-macosx_x64/bin/java
在 Catalina 之前,这些都没有给我带来任何问题......
所以问题是我应该进行什么调整才能使 JDK 在任何情况下都能工作?