External JDK for CI Unity Editor

We’re using dockerized Unity installations to build our Unity projects in a CI (Gitlab CI). We recently switched to a manually installed JDK instead of an embedded installation alongside Unity. Initially a project built for Android with this didn’t build because, of course, Unity wasn’t configured to use something other than the embedded JDK.

This however is where I’m currently stuck at. I was able to disable JdkUseEmbedded using a prefs file, however even after setting the Jdk11Path (and JdkPath, just for good measure) to /usr/lib/jvm/java-17-openjdk-amd64 (the path where the JDK is installed inside the container), Unity is not able to find the JDK installation:

DisplayProgressbar: Checking prerequisites
Android PostProcess task "Checking prerequisites" took 8.623 ms
DisplayProgressbar: Detect Java Development Kit (JDK)
UnityException: JDK not found
Java Development Kit (JDK) directory is not set or invalid. Please, fix it in Edit / Unity -> Preferences -> External Tools

I am able to retrieve the configured path using EditorPrefs.GetString("Jdk11Path") (and I’m also able to retrieve the JDK path on Windows configured using the preferences window), and I was also able to verify that this path exists and is a dictionary.

What would I need to do in order for Unity to be able to find the JDK installation?

Richard

P.S.: It’s slightly frustrating that all official documentation I found so far only refers to the Preferences window i.e. that nowhere it’s stated how you could define this in the preferences, using a command line argument, an Editor API, or in another manner that could be utilized for automation.

It seems like the issue was a JDK version not supported by Unity. Using JDK 11 instead of JDK 17 solved the issue.

However, this still indicates that the error message given (see above message) could be improved, since it didn’t indicate that the issue was a version mismatch, but rather an invalid path (i.e. a path that doesn’t exist or doesn’t contain a Java installation at all).

Please report a bug, so we can have this on our radar. Thank you!