A robust PowerShell script for easily installing any JDK from ZIP archive
Nothing. This is feature complete. Feel free to use this to make your own version how you want.
- Easy to use, predictable behaviour and easy to understand.
- Lots of checks in place to prevent broken installs.
- Self elevates for required admin rights, and keeps working directory.
- Easy ZIP archive selection with file dialogue.
- Validates ZIP archive for JDK. Won't accept non-JDK zip archives.
- Accepts both relative and absolute paths.
- Changes working directory to execution directory from system32 to prevent accidental installs to the system directory if script is started as admin from context menu.
- No file deleting code whatsoever. Only installs to empty directory. Creates directory if non-existant.
- Defaults to Program Files\Java{detected JDK name/version}\ on blank entry for quick installs.
- Sets both PATH and JAVA_HOME environment variables after extraction.
- Uses helper function instead of setx /M, which is known to have issue causinglimitations (e.a. deleting entire PATH values).
- Go to https://github.com/lemon07r/JDK-PowerShell-Installer-Script/blob/main/jdk_installer.ps1 Download the script file by right clicking Raw, then "Save link as". Or copy and paste the code into your editor of choice then save it as a .ps1 file.
- Run the saved .ps1 script as Administrator. You can do this by opening PowerShell as admin, and executing the script directly from there, or if you Set-ExecutionPolicy to allow scripts to run from other sources, this script will automatically prompt for admin rights to elevate it self.
- Now just follow the on-screen instructions, they're straightforward and simple enough. Make sure you have the JDK .zip you want to install from downloaded. This script works with most JDK versions, including various OpenJDK, and GraalVM EE distributions.
Copyright (c) 2023 Lamim