How to properly set JAVA_HOME in /etc/environment

reikje picture reikje · Jan 6, 2013 · Viewed 20.6k times · Source

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"

Answer

CerealKiller picture CerealKiller · Apr 30, 2014

Just write

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

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