不是有效的标识符

不是有效的标识符

本文介绍了-bash:导出:`“"JAVA_HOME =/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home"":不是有效的标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Mac机器上设置Java和Hadoop,并且这样做是使用以下命令:

I am trying to set up Java and Hadoop on my Mac machine, and in doing so, I am using this command:

$ echo export "JAVA_HOME=$(/usr/libexec/java_home)" >> ~/.bash_profile
$ source ~/.bash_profile

但是,当我输入source〜/.bash_profile时,会出现此错误:

However, when I type source ~/.bash_profile it gives me this error:

-bash: export: `"JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home"': not a valid identifier

为什么这么说?

推荐答案

这看起来更正确:

echo 'export JAVA_HOME="$(/usr/libexec/java_home)"' >> ~/.bash_profile

注意:

  • 使用标准ASCII引号,而不使用卷曲的智能引号".
  • 单引号用于确保在运行echo之前不评估命令替换,而是将其添加到.bash_profile中.
  • Standard ASCII quotes, not curly "smart quotes", are used.
  • Single quotes are used to ensure that the command substitution is not evaluated before the echo is run, but instead is added to your .bash_profile.

这篇关于-bash:导出:`“"JAVA_HOME =/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home"":不是有效的标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 16:55