I am using the following yaml for an Azure pipeline, but getting an error. Even though that image has Java 11 installed. Any idea what I am doing wrong?
Error:
##[error]Java 11 is not preinstalled on this agent
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
buildConfiguration: 'Release'
outputDirectory: '$(build.binariesDirectory)/$(buildConfiguration)'
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x86'
jdkSourceOption: 'PreInstalled'
TL;DR Use x64
instead of x86
in the JavaToolInstaller@0
task.
There are no x86
pre-installed JDKs in Microsoft hosted-agent windows-latest
(same as windows-2022
as of August 2024).
Sample pipeline:
trigger: none
pool:
vmImage: 'windows-latest'
steps:
- task: JavaToolInstaller@0
inputs:
versionSpec: '11'
jdkArchitectureOption: 'x64' # <-------------------------- replaced value
jdkSourceOption: 'PreInstalled'
Output of the installer task when running the pipeline:
Starting: JavaToolInstaller
==============================================================================
Task : Java tool installer
Description : Acquire a specific version of Java from a user-supplied Azure blob or the tool cache and sets JAVA_HOME
Version : 0.243.1
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/tool/java-tool-installer
==============================================================================
Use preinstalled JDK from C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.24-8\x64
JAVA_HOME is being set to: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.24-8\x64
JAVA_HOME_11_X64 is being set to: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.24-8\x64
Prepending PATH environment variable with directory: C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\11.0.24-8\x64\bin
Finishing: JavaToolInstaller
See the list of installed software in Microsoft-hosted build agents.