How to set JAVA_HOME in / etc / environment correctly

I am trying to add JAVA_HOME to the system area, and also add JAVA_HOME / bin to PATH (Ubuntu 12.04). If I add the following 2 lines to the end of / etc / environment, I can no longer log in. If I add 2 lines to / etc / profile, everything will work. Do you have a problem?

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

The following line already exists in / etc / environment (line 1):

 PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" 
+7
source share
2 answers

Just write

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

on your / etc / environment, without "export"

+10
source

/etc/environment should contain a set of environment variables defined as key = value pairs. This is not a shell script, so you cannot use shell commands in it like export .

+8
source

All Articles