When the Java Runtime Environment (JRE) to be used by LibreOffice is automatically detected by LibreOffice (e.g. on the first start of the program), the JAVA_HOME and PATH environment variables are currently not taken into account, i.e. they have no effect on the JRE that is selected. Possibly it would be a good idea to prefer the Java installations which these environment variables refer to over other Java installations on the system as they (JAVA_HOME, PATH) generally indicate which JRE should be used on the system. Thus, users/administrators can control which JRE is used if multiple JREs are installed on the system. Therefore, I think this setting should be taken into account by LibreOffice as well. It would also offer administrators an easy possibility to set a specific JRE for LibreOffice by providing a startup script that first sets the JAVA_HOME environment variable before starting LibreOffice (e.g. in large companies).
I have submitted a patch to Gerrit that implements this (https://gerrit.libreoffice.org/#/c/11392/) and would be very glad to receive feedback on both, the general idea, and the patch.
Michael Weghorn committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=40138cee6b6f19a7725f3ce9316f285b86366a06 fdo#83753: consider JAVA_HOME and PATH when selecting JRE It will be available in 4.5.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.
The functionality is now implemented on "master". JREs indicated by JAVA_HOME or PATH are preferred over others.
Stephan Bergmann committed a patch related to this issue. It has been pushed to "master": http://cgit.freedesktop.org/libreoffice/core/commit/?id=555f024f16d4407be3c9b0dbb15fb18c2f6f3b20 Related fdo#83753: Fix JVM_ONE_PATH_CHECK feature again It will be available in 4.5.0. The patch should be included in the daily builds available at http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More information about daily builds can be found at: http://wiki.documentfoundation.org/Testing_Daily_Builds Affected users are encouraged to test the fix and report feedback.