Ubuntu下桌面环境变量设置

在Ubuntu community上看见关于环境变量设置的文档:https://help.ubuntu.com/community/EnvironmentVariables

其中有一段

"/etc/bash.bashrc - This is is the system-wide version of the ~/.bashrc file. Ubuntu is configured by default to execute this file whenever a user enters a shell or the desktop environment.

按照字面意思, 当用户进入桌面环境时,bash.bashrc中设置的环境变量都应该生效。但是,情况却并非如此。 

仅在/etc/bash.bashrc中设置JAVA_HOME并将其加入PATH,在gnome中仍然无法启动eclipse,会被告知没有可用的JRE。

解决办法:

Ubuntu中,如果想让环境变量设置在整个桌面环境中生效,需要在/etc/profile中设置,而不是/etc/bash.bashrc

原文地址:https://www.cnblogs.com/daition/p/1734455.html