I installed adoptopenjdk, and noticed that my java variables such as JAVA_HOME are not being set on boot. It is my understanding that this should happen automatically thanks to the /etc/profile.d/alljava.sh file.
I tried with just one java version installed, and then tried with multiple installed, configured via update-alternatives, but still nothing.
I do not know much about Java, but things from /etc/profile.d/ are not set at boot (automaticaly or not).
The whole profile mechanism is used for a user that logs in.
Java is not ordinarily configured automatically.
Don’t know where you got your alljava.sh, I’ve never seen or heard of such a file so it’s being provided to you by something you’re doing uniquely.
The general recommendation to set your Java environment on bootup is to create a file /etc/profile.local (because you’re not supposed to edit /etc/profile directly) which contains your java environment settings.
An alternative solution less often used is to script your java environment variables and place the script in the directory /etc/profle.d
AFAIK everything any/all settings in /etc/ are read into the system on boot… of course as long as the system reads the file.
User specific settings are typically stored in the Use’s /home directory.
The system? What is that. IMHO only a process can read files. Just saying “the system” instead of defining which process reads what when is a bit vague.
That is correct. But that dos not mean that there aren’t any configuration files that are general for all users.
In this case, where we talk about “profile”, there is the profile as suggested by the ditributer and installed in /etc/profile. Inside /etc/profile we find
test -s /etc/profile.local && . /etc/profile.local
which thus allows for the system manager to add/change things in /etc/profile.local without touching /etc/profile which may be overwritten on an update).
There is also a whole section which starts with the comment
# Source profile.d files
which allows for applications to add there own stuff concentrated in simple files.
A user can have (and often does have) his .profile where he can add additions and changes (e.g. the PATH is defined in /etc/profile, the system manager can provide a different one in /etc/profile.local and the user can adapt that to her/his needs in ~/.profile).
And the whole handling is there to be used at the start of a shell (thus after user login). From
man bash
When bash is invoked as an interactive login shell, or as a non-interactive shell with the --login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. …
Now it is quite possible that other programs then shells do (try to) read from these different profile files. I assume that Desktop Environments will do so when started in about the same way as shells. But I doubt many other programs will do so.
Hi
The alljava.sh file is standard with openSUSE, but as stated in the script, it’s for the default java, you may need some tweaking if things are installed in a different location, better to set in the user profile…