Install Java silently using powershell in Azure Windows VM
Written by Akhil M Anil.
To install Java silently using PowerShell in Windows VM, follow the following steps:
Downloading Java can be done in two ways:
- Download your required Java version (Java Downloads | Oracle) to a folder in your Windows VM.
- Use PowerShell to Download Java to a folder.
Follow the below steps for downloading Java through PowerShell:
- Initially copy the Download link for your required Java version, Java file name, and Location where you want to download Java in your VM to a notepad
- Open PowerShell
- Run the following command in PowerShell
- $url = "<your-copied url>"
- $filename = "<file_name>"
- $dest = "<outputfile-location\$filename>"
- Invoke-WebRequest -Uri $url -OutFile $dest
- For Example:
- $url = "https://download.oracle.com/java/18/latest/jdk-18_windows-x64_bin.exe"
- $filename = "jdk-18_windows-x64_bin.exe"
- $dest = "C:\Users\akhilanil\Desktop\Java\$filename"
- Invoke-WebRequest -Uri $url -OutFile $dest
- Run the following command will download Java in the specified location.
Once java is downloaded, execute the following steps to install the java version through PowerShell.
- Execute the following commands to install Java Silently.
- Start-Process -Wait -FilePath $dest -ArgumentList "/s" -PassThru
- If you manually download Java in a folder, Open the same directory which contains the executable in PowerShell.
- Run the following command in PowerShell to install Java Silently.
- Start-Process -Wait -FilePath '.\<exe filename.exe>' -ArgumentList "/s" -PassThru
- For Example: Start-Process -Wait -FilePath '.\jdk-18_windows-x64_bin.exe' -ArgumentList "/s" -PassThru
4. The Java should be installed by now. You can validate it by opening a new PowerShell window and checking the version of Java by java -version
Very informative content.
ReplyDelete