Java文件保存在Commands文件夹而不是bin文件夹中

时间:2018-11-11 16:20:52

标签: java flutter homebrew homebrew-cask

我使用以下命令在MacBook Air上安装了JAVA

$ brew cask install java

发现所有假定位于/bin中的文件都存储在另一个名为/Commands的文件夹中,其路径如下:

/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands

enter image description here

因此,我将JAVA_HOME定义如下:

// Opened .bash_profile file
Hasans-Air:~ h_ajsf$ sudo code $HOME/.bash_profile
// Add the below to the .bash_profile file
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands
//Saved the file
//Updated env by:
Hasans-Air:~ h_ajsf$ source $HOME/.bash_profile
//Check for JAVA_HOME
Hasans-Air:~ h_ajsf$ echo $JAVA_HOME
/System/Library/Frameworks/JavaVM.framework/Versions/A/Commands

然后在运行flutter doctor来检查所有设置是否正确时,出现以下错误:

[!] Android toolchain - develop for Android devices (Android SDK 28.0.3) ✗ Cannot execute /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/bin/java to determine the version

这意味着Flutter正在寻找$JAVA_HOME/bin我没有空的!如何使Flutter忽略/bin或如何使brew cask考虑添加/bin

一个朋友建议删除openJDK:

Hasans-Air:~ h_ajsf$ brew cask uninstall java --force

然后将其替换为java8,并按照here的说明将JAVA_HOME设置为:

Hasans-Air:~ h_ajsf$ brew tap caskroom/versions
Hasans-Air:~ h_ajsf$ brew search "java*"
Hasans-Air:~ h_ajsf$ brew cask info java8
Hasans-Air:~ h_ajsf$ brew cask install java8
// Opened .bash_profile file
Hasans-Air:~ h_ajsf$ sudo code $HOME/.bash_profile
// Add the below to the .bash_profile file
export JAVA_HOME=$(/usr/libexec/java_home)
// Save the file
// Refresh the environment variables
Hasans-Air:~ h_ajsf$ source $HOME/.bash_profile
//Check for JAVA_HOME
Hasans-Air:~ h_ajsf$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_192.jdk/Contents/Home

但是我想真正使用openJDK

0 个答案:

没有答案