Why Is openSUSE Ignoring JAVA_HOME Even After Correctly Setting It?

Hello

I am running into an issue on my openSUSE Leap system where the JAVA_HOME environment variable is being ignored; even though I have set it correctly in both /etc/profile and .bashrc. :upside_down_face:

When I echo $JAVA_HOME, it shows the correct path (e.g., /usr/lib64/jvm/java-11-openjdk), but some applications like Maven / Tomcat still report that Java is not set or default back to the system version. I have also tried setting it with update-alternatives but no luck.

I made sure the Java version is installed & matches the expected architecture. Interestingly; a fresh user account does pick up the JAVA_HOME setting without issue. Could this be something related to systemd, login shells / some environment caching behavior in SUSE? :innocent:

I am wondering if anyone else has had this issue & knows how to make the setting consistent across GUI apps, terminal sessions & services. :upside_down_face: Checked https://forums.opensuse.org/t/setting-up-environment-variables/128241 related to this.

While trying to troubleshoot this; I also ended up reading about what is java and its history with cross-platform compatibility, which makes it even more surprising how setting it up can still be this inconsistent across Linux distributions. :innocent:

Any suggestions or workarounds would be much appreciated.

Thank you !! :slightly_smiling_face:

Hi,

this is complex, but profile is only read for login session, so all systemd-managed services (like tomcat ) will not use that ( and there is the possibility to override this in the service config as well).

And a .bashrc is only read for the user it belongs to. And both are of course only re-read on login so for your shells to pick up the changes you need to login and out again.