How to set JDK path used by dotnet build command

Simon 0 Reputation points


We build our .NET MAUI app for android using the dotnet publish command on the command line. During the build, the wrong version of the JDK (Java Development Kit) gets picked.

How can we specify the path to the JDK that should be used for the build?

We already tried setting the JAVA_HOME environment variable but without success. We are running the build on macOS.

Thank you for your help.

A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,959 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Simon 0 Reputation points

    I found the answer myself:

    To set a custom JDK path for the command, you can use a environment variable named JavaSdkDirectory

    that contains the JDK directory path.