I install Java on all my machines and used to add the java path and home variables to the user (or my user) bash profile but every time I added another user this is a manual step.
Until I found this small trick. Add a system wide profile path setting by creating a file in:
/etc/profile.d/filename
All files in profile.d are added to every users login. Much cleaner than adding it to every user’s profile.
This is the contents of my file:
/etc/profile.d/java-path.sh
export JAVA_HOME="/opt/java"
export PATH=$JAVA_HOME/bin:$PATH
These variables are set next time you log in with any user on that system.