且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何设置Homebrew安装的Java路径?

更新时间:2022-04-19 22:55:01

我使用 Maarten Mulders

我将以下内容添加到我的bash配置文件中(文件我的主目录中的 .bash_profile

I added the following to my bash profile (the file .bash_profile in my home directory).

alias j9="export JAVA_HOME=`/usr/libexec/java_home -v 9`; java -version"
alias j8="export JAVA_HOME=`/usr/libexec/java_home -v 1.8`; java -version"
alias j7="export JAVA_HOME=`/usr/libexec/java_home -v 1.7`; java -version"

当我想要更改为Java版本时,我只需执行 j7 在终端中。

When I want to change to a Java version, I simply execute j7 in the terminal.