Uyisebenzisa kanjani iBrew ukufaka iJava kwiMac

Unokuba neenguqulelo ezininzi zeJava kwi-Mac yakho.

Kule nqaku sibonisa indlela yokufaka iJava kwi-Mac usebenzisa i-Homebrew, kunye nendlela yokuvumela ukutshintshela phakathi kweenguqulelo ezahlukeneyo ezinje ngeJava8, Java11, Java13 kunye nohlobo lwamva nje lweJava.



Izinto ezifunwa kwangaphambili

Ngaphambi kokuba siqale, qiniseka ukuba ufake i-Homebrew kwi-Mac yakho. Ukuba akunjalo, ungayifaka nge:


$ ruby -e '$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)'

Emva koko, faka i-Cask yasekhaya

$ brew tap homebrew/cask-versions $ brew update $ brew tap caskroom/cask

Faka iNguqulelo yamva nje yeJava usebenzisa iBrew

Ukufaka uhlobo lwamva nje lweJava, konke okufuneka ukwenze yile:


$ brew cask install java

Faka iinguqulelo ezithile zeJava (Java8, Java11, Java13)

Ukufaka iinguqulelo zangaphambili okanye ezithile zeJDKs, ungazifumana kwiAdoptOpenJDK:



$ brew tap adoptopenjdk/openjdk $ brew cask install adoptopenjdk8 $ brew cask install adoptopenjdk11 $ brew cask install adoptopenjdk13

Tshintsha phakathi kweendidi ezahlukeneyo zeJava

Ukuba ufuna ukutshintshela phakathi kweenguqulelo ezahlukeneyo zeJava, kuya kufuneka ukongeza oku kulandelayo .bash_profile |.

Kule meko, sifuna ukubanakho ukutshintsha phakathi kweJava8 kunye neJava11:

export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8) export JAVA_11_HOME=$(/usr/libexec/java_home -v11) alias java8='export JAVA_HOME=$JAVA_8_HOME' alias java11='export JAVA_HOME=$JAVA_11_HOME' # default to Java 11 java11

Layisha kwakhona .bash_profile ukuze izibizo ziqale ukusebenza:


$ source ~/.bash_profile

Emva koko, unokusebenzisa izibizo ukutshintshela phakathi kweenguqulelo ezahlukeneyo zeJava:

$ java8 $ java -version java version '1.8.0_261'

Isiphelo

Kule posi sifunde indlela yokufaka nayiphi na inguqulelo yeJava kwi-Mac usebenzisa i-Homebrew.