找不到JAVA_HOME作为Sudo [英] JAVA_HOME not found as Sudo
问题描述
我在运行Jar文件的Linux机器上有一个bash脚本.以普通用户身份登录时,我没有运行脚本的权限,但它会显示以下日志:
I have a bash script on a Linux box that runs a Jar file. When logged in as a regular user I don't have permission to run the script, but it prints the following log:
*INFO * Using JVM found at /opt/jdk6/bin/java
当我尝试将脚本与Sudo一起使用时,它给出了:
When I try to use the script with Sudo though, it gives:
*ERROR* Unable to locate java, please make sure java is installed and JAVA_HOME set
我已经将JAVA_HOME
设置为上述相同的路径-可以通过echo $JAVA_HOME
&它也被设置为脚本中的一个选项.我很高兴脚本不是问题-它是默认的CQ5控制脚本&我正在其他数十个盒子上使用它,没有问题.只是不确定在&上面我在做什么错.假设这是我在Linux设置中缺少的东西吗?
I've set JAVA_HOME
to the same path above — can see it with echo $JAVA_HOME
& it's also set as an option within the script. I'm happy that the script isn't the issue — it's a default CQ5 control script & I'm using it on dozens of other boxes without issue. Just unsure what I'm doing wrong above & presume it's something I'm missing re Linux set-up?
当我运行sudo
命令时,它是否可以访问我自己设置的JAVA_HOME
?
When I run the sudo
command, does it have access to the JAVA_HOME
that I set up as myself?
推荐答案
默认情况下,sudo
将清除生成的命令的环境.传递-E
保留它:
By default, sudo
will cleanup the environment of the spawned commands. Pass -E
to keep it:
sudo -E env
比较:
sudo env
这篇关于找不到JAVA_HOME作为Sudo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!