1

I am using the 12.04LST, and I am trying to install the oracle jdk7 manually.

Then I update the /etc/environment to set the PATH variable.

This is the original file content:

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

And I update it as this:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
JAVA_HOME="/usr/lib/jvm/jdk1.7"
PATH="$PATH:$JAVA_HOME/bin"

Then I make it work using:

source /etc/environment

Then I type java and javac, and it worked.

However after I reboot my computer, I was kept at the login screen.

Then I use ctrl+alt+f2 to go the terminal.

And update the /etc/envrionment like this:

/usr/bin/sudo /usr/bin/nano /etc/emvrionment to the following:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
JAVA_HOME="/usr/lib/jvm/jdk1.7"

Then I can login again.

Now I have two questions:

  1. Why I can not login if I add the line PATH="$PATH:$JAVA_HOME/bin" in /etc/envirionment?

  2. Is variables set in /etc/environment is available for all the user?

4
  • In fact, it does not. It does not told why user can not login.
    – hguser
    Apr 25, 2013 at 0:23
  • Same problem here. Try to update the alternatives rather to set environment variable. sudo update-java-alternatives -s /usr/lib/jvm/jdk1.7....full path needed here see if works (with java and javac) . Alternatively you can try to set the path directly to PATH (without create a new variable) PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7"
    – NickTux
    Apr 25, 2013 at 0:29
  • I do not prefer this manner. Since I have to add all the commands like java javac and something else.
    – hguser
    Apr 25, 2013 at 0:34

2 Answers 2

1

/etc/environment is not executed as a script but read as a configuration file, so no shell expansion is available, thus variables can't be read.

If you wan't to use variables, resort to use session-wide variables in ~/.pam_environment.

Reference

0

Ok. I checked it - it must depends of PAM somehow, if write to /etc/environment this: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7/bin" and then source it, it will work fine and you'll be able to login

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .