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:


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

### begin crouton-generated environment variables
### end crouton-generated environment variables

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.

  • 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

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

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



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

  • 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? – Wellington Oliveira 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

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

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.