I am trying to build a Java Maven application and run some tests against a Postgres db.

However, the java app uses JDK 13 and the Azure hosted agent ubuntu doesn't have this default installed. As such, I use the script task to install it, then use it during the Maven build.

However, I tried several config's and in all Maven keeps complaining that it can not found any JDK 13 installed.

The last config I tried is listed below, in which I install it through a script and then use the JavaToolInstaller task to make it available (ensuring the Java\_home is set and the java can be found in the path.
I then get the error

```
##[error]Java 13 is not preinstalled on this agent

```

I also tried it without the JavaToolInstaller task and then export JAVA\_HOME and modify the PATH in the script, but then Maven complaints it can not find JDK 13...

Please some help how to use JDK 13 on an ubuntu agent during the maven build?

Azure pipeline snippet:

```
    variables:
    MAVEN_CACHE_FOLDER: $(Pipeline.Workspace)/.m2/repository
    MAVEN_OPTS: "-Dmaven.repo.local=$(MAVEN_CACHE_FOLDER)"
    JAVA_HOME : "/usr/lib/jvm/openjdk-13-jdk"
    PATH: $(JAVA_HOME)/bin:$(PATH)
    service_name: backend
    mygetUsername: myUserName
    mygetPassword: myPassword

resources:
    containers:
        - container: postgres
          image: postgres:11.6-alpine
          ports:
              - 5432:5432
          env:
              POSTGRES_DB: default
              POSTGRES_USER: default
              POSTGRES_PASSWORD: default
              POSTGRES_HOST_AUTH_METHOD: trust

stages:
    - stage: create_artifact
      displayName: Create artifact
      jobs:
          - job: build
            displayName: Build, test and publish artifact
            services:
                postgres: postgres
            steps:
                - script: |
                    sudo apt-get install openjdk-13-jdk  
                  displayName: Installing JDK 13

                - task: JavaToolInstaller@0
                  displayName: Using JDK 13
                  inputs:
                    versionSpec: "13"
                    jdkArchitectureOption: x64
                    jdkSourceOption: "PreInstalled"

                - task: Cache@2
                  displayName: Cache Maven local repo
                  inputs:
                      key: 'maven | "$(Agent.OS)" | backend/pom.xml'
                      restoreKeys: |
                          maven | "$(Agent.OS)"
                          maven
                      path: $(MAVEN_CACHE_FOLDER)
                - task: Maven@3
                  name: maven_package
                  displayName: Maven package
                  inputs:
                      goals: "package"
                      mavenPomFile: "backend/pom.xml"
                      options: '--settings backend/.mvn/settings.xml -DmygetUsername=$(mygetUsername) -DmygetPassword=$(mygetPassword)'
                      mavenOptions: "-Xmx3072m $(MAVEN_OPTS)"
                      javaHomeOption: "JDKVersion"
                      jdkVersionOption: "1.13"
                      mavenAuthenticateFeed: true

```