On Windows, java uses an environment variable, one named JAVA_HOME and it also might use the Path variable to find the java binaries.
New Unity comes bundled with Java so it shouldn’t need any external java “stuff”.
Removing them should fix any java issues, as long as you choose to install and use the bundled java.
However there is another bug on unity that leaves some path bars inverted and apparently this bugs the java usage.
Java 9 (JDK 9) support by Unity Android page-3#post-5724547
So I now just use a script to fix this stuff automatically…
string newJDKPath = EditorApplication.applicationPath.Replace("Unity.exe", "Data/PlaybackEngines/AndroidPlayer/OpenJDK");
if (Environment.GetEnvironmentVariable("JAVA_HOME") != newJDKPath)
{
Environment.SetEnvironmentVariable("JAVA_HOME", newJDKPath);
}
Put in on a static constructor on a class marked with [InitializeOnLoad] on the Editor folder of your project.