How to set JDK path used by dotnet build command

Simon 0 Reputation points
2024-04-29T07:00:01.4566667+00:00

Hello,

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.

.NET MAUI
.NET MAUI
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
    2024-04-29T14:51:17.85+00:00

    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.