0.环境
windows11pro
1.工具下载
GitHub - Mu-L/JEnv-for-Windows: Change your current Java version with one line
or
JEnv-for-Windows:Change your current Java version with one line - GitCode
2.执行jenv 初始化
2.1 问题:PowerShell 未对文件\XXX.ps1进行数字签名
解决问题参照url:关于执行策略 - PowerShell | Microsoft Learn
执行以下命令:
Get-ExecutionPolicy -List
目标结果:
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine RemoteSigned
执行:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned-Scope CurrentUser
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned-Scope LocalMachine
再执行:命令参照:Unblock-File - PowerShell - SS64.com
Get-ChildItem 文件夹绝对路径 -File -Recurse | Unblock-File
最后执行 jenv 成功
jdk压缩包下载地址:Java Archive | Oracle
下载放入指定目录,参照 JEnv-for-Windows的使用文档执行命令
jenv add jdk17 D:\middleware\java\jdk-17.0.10
jenv use jdk17
jenv local jdk17
java -version