This function is used by all of the tika() functions internally as the default value to its java parameter.
This function tries to find an environmental variable using Sys.getenv("JAVA_HOME").
It looks for the java executable inside the bin directory in the JAVA_HOME directory.
If you want to use a specific version of Java, set the JAVA_HOME variable using Sys.setenv(JAVA_HOME = 'my path'),
where 'my path' is the path to a folder that has a bin directory with a java executable.
For example, on Windows 10 JAVA_HOME might be C:/Program Files (x86)/Java/jre1.8.0_171.
On Ubuntu and OS X, it might be the /usr directory.
The JAVA_HOME variable can also be set to persist over sessions.
Add the path to the .Rprofile by adding Sys.setenv(JAVA_HOME = 'my path'), and it will use that every time R is started.