How to set the Java path installed by Homebrew?

后端 未结 1 1651
生来不讨喜
生来不讨喜 2021-02-06 01:05

Java 9 is installed in my MacBook (OS X 10.11 El Capitan). As I needed Java 8, I\'ve installed it using Homebrew.

$ brew cask install java8

How

1条回答
  •  余生分开走
    2021-02-06 01:45

    I use the method suggested by Maarten Mulders.

    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"
    

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

    0 讨论(0)
提交回复
热议问题