简体   繁体   English

如何使Mac Java_Home工具正常工作?

[英]How can i make Mac Java_Home tool to work?

How can i make java_home tool(ie /usr/libexec/java_home) to work on my mac?I am a mac newbie.Mac Java-home tool says unable to find JVM installed but JVM is installed on my machine and the java -version return true as shown below 我如何使java_home工具(即/ usr / libexec / java_home)在我的Mac上工作?我是Mac新手.Mac Java-home工具说无法找到安装的JVM,但我的机器和Java -version上都安装了JVM返回true,如下所示

    $ /usr/libexec/java_home -V
Unable to find any JVMs matching version "(null)".
Matching Java Virtual Machines (0):

Default Java Virtual Machines (0):

No Java runtime present, try --request to install

```$ java -version
openjdk version "11.0.2" 2019-01-15 LTS
OpenJDK Runtime Environment Zulu11.29+3-CA (build 11.0.2+7-LTS)
OpenJDK 64-Bit Server VM Zulu11.29+3-CA (build 11.0.2+7-LTS, mixed mode)

Open up Terminal.app (Applications >> Utilities >> Terminal) 打开Terminal.app(应用程序>>实用程序>>终端)

Type: nano .profile 类型: nano .profile

add this to the end of the .profile file: 将其添加到.profile文件的末尾:

JAVA_HOME=/Library/Java/Home
export JAVA_HOME;

Save and exit (ctrl-x and y to confirm) 保存并退出(ctrl-x和y确认)

--- edit -编辑

Only now I saw, you are using open jdk, try it: 直到现在我看到,您正在使用open jdk,尝试一下:

Before setting the path make sure that java is installed by checking the directory 在设置路径之前,请通过检查目录来确保已安装java

terminal > type ls /Library/Java/JavaVirtualMachines/ 终端>输入ls /Library/Java/JavaVirtualMachines/

You will see java versions installed 您将看到安装了Java版本

Then in .bash_profile 然后在.bash_profile中

JAVA_HOME=/Library/Java/JavaVirtualMachines/<version>.jdk/Contents/Home
export JAVA_HOME

terminal type source ~/.bash_profile to reload 终端类型source ~/.bash_profile重新加载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM