优秀的编程知识分享平台

网站首页 > 技术文章 正文

Mac 下 安装Java 环境 install Java

nanyue 2024-10-01 13:01:54 技术文章 9 ℃

mac os install java

mac 下安装java环境

终端下直接打印版本号

java -version

No Java runtime present, requesting install.

提示没有安装:然后弹出窗口提示去安装

https://www.oracle.com/technetwork/java/javase/downloads/index.html

https://www.oracle.com/java/technologies/javase-downloads.html

https://www.java.com/en/download/mac_download.jsp

这里暂时没有用JDK安装其实性质一样的

https://www.oracle.com/java/technologies/javase-downloads.html
https://www.oracle.com/java/technologies/javase-jdk15-downloads.html 这里可以下载jdk

跳转之后下载jre这个就可以

jre-8u261-macosx-x64.dmg

下载之后对dmg文件双击可以即可

安装之后可以通过System Preferences中查看到


点击Java可以看到一些设置


注意这个路径/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java

/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version

java version "1.8.0_261"

Java(TM) SE Runtime Environment (build 1.8.0_261-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode

直接到这个目录中去

? bin pwd

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin

? bin ls

ControlPanel javaws keytool policytool servertool

_javaws jcontrol orbd rmid tnameserv

java jjs pack200 rmiregistry unpack200

? bin ./java -version

java version "1.8.0_261"

Java(TM) SE Runtime Environment (build 1.8.0_261-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

修改下环境变量,我的是zsh所以修改.zshrc

? ~ cat .zshrc|grep JAVA

export JAVA_HOME=/Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/lib:$JAVA_HOME/jre/bin
注意上面/Library/Internet\ Plug-Ins

Internet\ Plug-Ins是空格所以加了\来反转下

使得配置生效

soure .zshrc

然后打印下版本看看

? ~ java -version

java version "1.8.0_261"

Java(TM) SE Runtime Environment (build 1.8.0_261-b12)

Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)

? ~ echo $JAVA_HOME

/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home

参考版本:

Tags:

最近发表
标签列表