etc/environment == $PATH?

I try to fix a problem with my Android Studio Installation and for that I want to edit the $PATH variable and the $JAVA_HOME variable global and not only for one session.

As I described here (Oracle Java JDK Installation) my Android Studio does not find my JAVA JDK.

My question now: when I type echo $PATH, I receive:

/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin

but I already edited my environment file (./etc/environment) to:

### begin crouton-generated environment variables
### end crouton-generated environment variables
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/lib/python2.7:/usr/lib/google_appengine:/usr/lib/appengine-java-sdk-1.9.40/bin"

Why does the $PATH variable not change and is not affected by my edit?

Where can I edit the $JAVA_HOME variable? I cannot find the correct file for that.

Thank you very much for your support.

3

2 Answers

You need to log out of your user session and log back in again for changes made to /etc/environment to take effect.

But you can make it work immediately by running this:

source /etc/environment && export PATH

I found that very useful command here on Stack Overflow

You must add the code in ~/.profile. Example:

Make a copy of path variable before doing this procedure.

In ~/.profile, there is a section like this:

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then PATH="$HOME/bin:$PATH"
fi

So, add at this at the end of the file:

PATH="/usr/lib/jvm/java-8-oracle:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/lib/appengine-java-sdk-1.9.40/bin:**$PATH**"
JAVA_HOME="/usr/lib/jvm/java-8-oracle:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/usr/lib/appengine-java-sdk-1.9.40/bin"

The line above will add the directories in the existing path.

5

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like