1

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
  • What is the path to your "environment file"?
    – edwinksl
    Jul 27 '16 at 2:22
  • Thanks for your reply. It is located at ./etc/environment
    – Andre
    Jul 27 '16 at 6:29
  • Do what @Zanna said in her answer and it should work.
    – edwinksl
    Jul 27 '16 at 6:30
3

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

1

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 English is not perfect, but it's certainly not bad.
    – wjandrea
    Jul 27 '16 at 3:18
  • Thanks for your reply. It worked so far. I was able to edit my PATH and JAVA_HOME variable permanently. Unfortunatly, my Android Studio error still occurs. I literally have no idea what to do now.
    – Andre
    Jul 27 '16 at 6:55
  • Did you already tried add in /etc/environment and do logout/login? Jul 27 '16 at 13:17
  • Yeah, more than once. I have now edited both ~/.profile and etc/environment with the same PATH + JAVA_HOME in ~/.profile.
    – Andre
    Jul 27 '16 at 23:47
  • 1
    Now it works. Had to fix two more things in Android Studio. (askubuntu.com/questions/801104/oracle-java-jdk-installation/…)
    – Andre
    Jul 28 '16 at 1:28

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.