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"
To set JAVA_HOME, do the following: Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1. 6.0_02.
If you're doing any sort of development, or building with Maven or Ant, you need to point to the JDK (Java Development Kit) where utilities such as javac (the Java Compiler) reside. Otherwise, you can point to the JRE (Java Runtime Environment). The JDK contains everything the JRE has and more.
Just write
JAVA_HOME="/usr/lib/jvm/java-7-oracle"
on your /etc/environment, without the "export"
/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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With