我已经在路径上安装了 JDK /usr/lib/jvm/java-8-oracle。要设置JAVA_HOME变量,我/etc/environment 在 gedit 中打开并添加:
JAVA_HOME="/usr/lib/jvm/java-8-oracle" 到它。
但是我在将其另存为时出错:
Could not save the file “/etc/environment”.
You do not have the permissions necessary to save the file. Please check that you typed the location correctly and try again.
Run Code Online (Sandbox Code Playgroud)
哪里出错了?如何设置 JAVA_HOME 变量?
我的shell脚本代码如下:
echo "Enter file name";
read fname;
if [-f$fname];
then
echo "File already exists";
fi`
Run Code Online (Sandbox Code Playgroud)
但是,当我运行脚本时,出现此错误:
[-ffile]: not found
Run Code Online (Sandbox Code Playgroud)
我试过间距,-f $fname但我仍然遇到同样的错误。为什么会发生这种情况,我该如何解决?