How to properly set JAVA_HOME in /etc/environment

♀尐吖头ヾ 提交于 2019-12-31 13:29:48

问题


I am trying to add JAVA_HOME system-wide and also add JAVA_HOME/bin to PATH (Ubuntu 12.04). If I add the following 2 lines at the end of /etc/environment, I cannot login anymore afterwards. If I add the 2 lines to /etc/profile everything works. Wheres the problem?

export JAVA_HOME="/usr/lib/jvm/java-7-oracle"
export PATH="$PATH:$JAVA_HOME/bin"

There is already the following line in /etc/environment (line 1):

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

回答1:


Just write

JAVA_HOME="/usr/lib/jvm/java-7-oracle"

on your /etc/environment, without the "export"




回答2:


/etc/environment is supposed to contain a set of environment variables given as key=value pairs. It is not a shell script, so you can't use shell commands such as export in it.



来源:https://stackoverflow.com/questions/14183934/how-to-properly-set-java-home-in-etc-environment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!