Silent install of OpenJDK MSI in PowerShell

DJViking 21 Reputation points
2021-05-20T12:19:36.83+00:00

I am trying to silent install an MSI in PowerShell. The OpenJDK MSI downloaded from AdoptOpenJDK.

Need silent install because I am doing it when building my Windows JDK11 docker image.

First download the AdoptOpenJDK OpenJDK 11

Invoke-WebRequest https://api.adoptopenjdk.net/v3/installer/latest/11/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk?project=jdk -OutFile C:\Temp\openjdk11.msi

Trying with silent install:

Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\Temp\openjdk11.msi", "ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome", "INSTALLDIR='C:\Program Files\Java'", /quiet

The install process just hangs there forever.

Got a solution. It works when running it manually in PowerShell, but hangs still with docker build.
I am able to run the PowerShell command manually

 docker run -it -v C:\Temp:C:\Temp:rw -w C:\Temp mcr.microsoft.com/windows:1903 powershell
 Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\Temp\openjdk11.msi", 'ADDLOCAL="FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome"', 'INSTALLDIR="C:\Program Files\Java\jdk-11\"', /quiet, /norestart -Verb RunAs

When running the command in Docker build, it still hangs forever.

 Step 5/15 : ADD https://api.adoptopenjdk.net/v3/installer/latest/11/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk?project=jdk C:\Temp\openjdk11.msi
Downloading [==================================================>]  173.4MB/173.4MB

 ---> 387ac55cb949
Step 6/15 : RUN Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\Temp\openjdk11.msi", 'ADDLOCAL="FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome"', 'INSTALLDIR="C:\Program Files\Java\jdk-11\"', /quiet, /norestart -Verb RunAs
 ---> Running in 1fd5fd30c901

My Dockerfile

 # escape=`

FROM mcr.microsoft.com/windows:1903 AS jdk11

SHELL [ "powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ADD https://api.adoptopenjdk.net/v3/installer/latest/11/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk?project=jdk C:\Temp\openjdk11.msi
RUN Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\Temp\openjdk11.msi", 'ADDLOCAL="FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome"', 'INSTALLDIR="C:\Program Files\Java\jdk-11\"', /quiet, /norestart -Verb RunAs
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Anonymous
    2021-05-21T01:41:39.96+00:00

    Hi,

    Please check to see if this works.

    Start-Process -Wait -FilePath msiexec -ArgumentList /i, "C:\Temp\openjdk11.msi", "ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome", 'INSTALLDIR="C:\Program Files\Java"', /quiet -Verb RunAs  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.