1

There are several entries in stackoverflow to this subject. e.g. here

Why does it not work on my computer with Debian-10 (Buster)? I did 3 trial:

  1. put a file named 90java.conf below /etc/environment.d holding

    JAVA_HOME=/usr/lib/jvm/default-java

  2. put a file named java-env.sh below /etc/profile.d holding

    export JAVA_HOME=/usr/lib/jvm/default-java

  3. add the same text at the end to /etc/profile

    export JAVA_HOME=/usr/lib/jvm/default-java

and restarted Debian at each trial.

Than opened a command window and entered

echo $JAVA_HOME

The response was always an empty line. Like to understand what I do not have grasped about environment variables on startup.

added later:

Entering the export statement to /etc/bash.bashrc solved my problem.

However, I'd like to understand what is different to the /etc/environment or /etc/profile approach. Why do environment variables do not show up in that case?

ngong
  • 754
  • 1
  • 8
  • 23

1 Answers1

1

Setting like this are only relevant in a specific context. For example your shell, where you want to work with software and tools.

Thus, the solution is actually much simpler than all what you have tried. You have to do this in your private/local environment. But it depends on your shell.

If you have bash (or similar shells bash, sh, dash,...) best is edit the file ~/.profile and add export JAVA_HOME=/usr/lib/jvm/default-java there. If you have other shells find our the correct equivalent file. For csh it would be ~/.cshrc etc.

Ralf Ulrich
  • 1,575
  • 9
  • 25
  • What is the specific context for *all users*? As I understood the link I gave above, adding environment variable definitions to */etc/profile* should be relevant for all users. But I do something wrong and like to understand what is wrong. – ngong Oct 25 '21 at 13:41