Macro: How to get path LO detected for JRE

When installed JRE LO will show this JRE in tools …
Now I try to get the path of the JRE, which has been found, for executing a shell-command with java on different systems.
But: How do I get the path LibreOffice detected?
Found this:

msgbox Environ("JAVA_HOME")

but it isn’t working on Windows. Don’t know if it is working on Mac.

It may work on Windows (if Java was installed with a setting to set that environment variable - not the case these days in many packages); but even if it would, it’s not the same Java as configured in LO - it may happen to be the same, or it may be different (e.g., of different bitness, or even configured manually).

I’m not sure we expose this in an API.