Script to switch from Oracle Java to Temurin.
This repo contains a PowerShell script for Windows and a Bash script for macOS. Both work roughly in the same way:
- Look for Oracle JREs on the system.
- Look for Oracle JDKs on the system.
- For every installation found, ask user if Oracle Java should be replaced by a corresponding version of Eclipse Temurin.
- If user confirms, fetch Temurin installer for the corresponding feature release via the Adoptium API and install.
- If installation is successful, remove (uninstall) Oracle Java.
- (Windows only) Fix JAVA_HOME if it was defined and was pointing to a Java installation that got removed.
- (Windows only) Fix PATH such that the replacement Temurin JDK or JRE becomes the new default Java.
- Open a PowerShell prompt.
- Make sure that the execution policy allows execution of scripts:
PS> Get-ExecutionPolicy
Restricted
# Note: '-Scope Process' limits the change to the current prompt. No need to change it back afterwards.
PS> Set-ExecutionPolicy -ExecutionPolicy Unrestricted '-Scope Process'
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): Y
PS>
- Get the script:
# Note: 'curl.exe' not 'curl'. The former invokes the native cURL binary, the latter is an alias for Invoke-WebRequest.
PS> curl.exe -o o2t.ps1 https://raw.githubusercontent.com/afrischknecht/o2t/v2.0.2/win/o2t.ps1
- Execute it:
PS> .\o2t.ps1
- Follow the on-screen instructions. Questions can be answered by typing either
y
orn
followed by↵ Return
. (Sometimesi
is also offered as an option.)
- Open Terminal.
- Get the script:
% curl -o o2t.sh https://raw.githubusercontent.com/afrischknecht/o2t/v2.0.2/mac/oracle2temurin.sh && chmod u+x o2t.sh
- Execute it:
% ./o2t.sh
- Follow the on-screen instructions. Questions can be answered by typing either
y or n
. (Sometimesi
is also offered as an option.)