前言
從日志的報(bào)錯(cuò)信息可以看出, /Library/Internet
大概率是因?yàn)橄到y(tǒng)安裝的jdk
路徑包含空格導(dǎo)致腳本啟動(dòng)失敗
為什么能看出來(lái)是
jdk
路徑的問(wèn)題, 那是因?yàn)橛龅竭@種問(wèn)題多了, 基本上也知道哪里會(huì)問(wèn)題
特別是因?yàn)橹虚g升級(jí)了mac
的系統(tǒng), 那各種問(wèn)題都有, 都想回退系統(tǒng)版本了
解決辦法
一. 改系統(tǒng)配置文件
1. 系統(tǒng)配置: /etc/profile
- 能改, 但對(duì)于高版本的
mac
系統(tǒng), 改了也生效不了, 除非一些特別的操作, 個(gè)人覺(jué)得風(fēng)險(xiǎn)太大, 沒(méi)有繼續(xù)嘗試
2. 用戶配置: ~/.bash_profile
- 使用
vim
命令打開(kāi)~/.bash_profile
, 在文件最后, 添加如下內(nèi)容
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
export PATH=$PATH:$JAVA_HOME/bin
- 讓改動(dòng)生效(命令):
source ~/.bash_profile
查詢自己mac安裝的各類jdk路徑
/usr/libexec/java_home -V
-bash-3.2$ /usr/libexec/java_home -V Matching Java Virtual Machines (5): 13.0.2 (x86_64) "Oracle Corporation" - "Java SE 13.0.2" /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home 11.0.7 (x86_64) "Oracle Corporation" - "Java SE 11.0.7" /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home 1.8.301.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home 1.8.0_301 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home 1.8.0_221 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
二. 改啟動(dòng)腳本
1. 指定腳本的jdk
路徑
- 從報(bào)錯(cuò)提示, 確實(shí)需要修改的啟動(dòng)腳本:
runserver.sh
- 使用命令
/usr/libexec/java_home -V
查詢當(dāng)前mac
已安裝的jdk
路徑
-bash-3.2$ /usr/libexec/java_home -V
Matching Java Virtual Machines (5):
13.0.2 (x86_64) "Oracle Corporation" - "Java SE 13.0.2" /Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home
11.0.7 (x86_64) "Oracle Corporation" - "Java SE 11.0.7" /Library/Java/JavaVirtualMachines/jdk-11.0.7.jdk/Contents/Home
1.8.301.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
1.8.0_301 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home
1.8.0_221 (x86_64) "Oracle Corporation" - "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
我選擇的版本是1.8
路徑是:/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
- 使用命令
vim {$path}/runserver.sh
({$path}
表示腳本所在的目錄/路徑 ) - 參考下面代碼, 將
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
添加到啟動(dòng)腳本里
#===========================================================================================
# Java Environment Setting
#===========================================================================================
error_exit ()
{
echo "ERROR: $1 !!"
exit 1
}
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
[ ! -e "$JAVA_HOME/bin/java" ] && error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)!"
# force set java_home
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home
# force set java_home
export JAVA="$JAVA_HOME/bin/java"
export BASE_DIR=$(dirname $0)/..
export CLASSPATH=.:${BASE_DIR}/conf:${CLASSPATH}
- 保存并退出
:wq
, 重啟 RocketMQ 即可
參考來(lái)源
naco mac 啟動(dòng)報(bào)錯(cuò) /Library/Internet: No such file or directory
本文摘自 :https://www.cnblogs.com/