command not found xxx Mac端环境变量配置

问题一:mongod: command not found

1、打开终端 输入命令echo $PATH,我们就可以看到配置的有哪些环境变量,这里仅能查看并不能修改

echo $PATH

2、输入命令sudo vi ~/.bash_profile 添加环境变量,如某个你安装目录下的bin: /usr/local/mongodb/bin

export PATH=/usr/local/mongodb/bin:$PATH  

3、Esc键 :wq 保存退出,然后刷新:source ~/.bash_profile

source ~/.bash_profile

Error: Could not create the Java Virtual Machine.

Java的默认安装目录为 /Library/Java/JavaVirtualMachines/,终端进入Java默认安装目录下的Home文件

cd /Library/Java/JavaVirtualMachines/jdk-18.0.1.1.jdk/Contents/Home  
sudo -i vi /etc/.bash_profile

输入密码并回车,在打开的文件中输入以下内容

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-18.0.1.1.jdk/Contents/Home/
CLASSPAHT=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH:
export JAVA_HOME
export CLASSPATH
 export PATH

完成后按esc键退出编辑,再输入:wq 并回车保存刚刚的操作,终端输入 source /etc/.bash_profile 使配置生效

source /etc/.bash_profile
# 终端分别输入java和javac 校验是否配置成功
java
Javac 

你可能感兴趣的:(command not found xxx Mac端环境变量配置)