0

I added the following in /etc/profile so that all my users can see the path

export JAVA_HOME=/opt/jdk11
export PATH=$PATH:$JAVA_HOME/bin

But after restarting my laptop, I cannot see the changes using echo $JAVA_PATH. I thought there is an order for how the scripts are loaded. and Also, If I was to add this changes into a separate sh file in /etc/profile.d, it's supposed to do the same. So why is it that it's failing to see the path changes.

  • 1
    JAVA_PATH or JAVA_HOME? You assign one but mention the other in the echo. – ilkkachu Mar 13 at 22:15
  • @ilkkachu thanks for correcting the typo – ha9u63ar Mar 13 at 22:16
  • 1
    Just asking to verify that you didn't accidentally set the wrong variable. You could edit your question to clarify it, just so that no-one else makes the wrong interpretation. – ilkkachu Mar 13 at 22:21
  • See wiki.debian.org/EnvironmentVariables for the official stance. – Ferenc Wágner Mar 14 at 8:36
0

Perhaps you are testing in a non-interactive shell. For interactive shells, both /etc/profile and /etc/bash.bashrc are sourced, but for non-interactive shells, only /etc/bash.bashrc is sourced. You might try putting your variables in that file.

/etc/profile, ~/.bash_profile, ~/.bash_login, ~/.profile and related files on other shells are discussed at length in this answer.

  • I think it's the latter. Thanks for explaining the interactive shell concept. Appreciated! – ha9u63ar Mar 13 at 22:41

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.