java - 如何使用 powershell 脚本下载最新的 java 版本 8
问题描述
我正在使用以下命令在其中一个 Windows 打包程序实例上安装 Java,但是,我遇到了以下错误;
Cannot index into a null array.
At line:1 char:94
+ ... content | %{[regex]::matches($_, '(?:<a title="Download Java software ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
命令:-
[Net.ServicePointManager]::SecurityProtocol = "tls12"
$URL = (Invoke-WebRequest -UseBasicParsing https://www.java.com/en/download/manual.jsp).Content | %{[regex]::matches($_, '(?:<a title="Download Java software for Windows .64-bit." href=")(.*)(?:">)').Groups[1].Value}
Invoke-WebRequest -UseBasicParsing -OutFile jre8.exe $URL
Start-Process .\jre8.exe '/s REBOOT=0 SPONSORS=0 AUTO_UPDATE=0' -wait
看起来 Oracle 已从导致错误的网页中删除了标题字符串内容。是否有另一种方法/命令可以使用 powershell 安装它?
解决方案
推荐阅读
- visual-studio-code - prettier 扩展将使用 'node_modules/prettier/index.js' 进行验证
- java - JProfiler 调用堆栈拆分
- python - 使用 discord.py on_message() 上传 txt
- javascript - WeakMap 显示相同代码的不同结果
- r - 有效地为每行小标题创建一个 JSON
- java - 如何使用jackson映射动态json属性名称以进行spring rest模板请求
- javascript - 按对象索引组合对象数组
- reactjs - 错误:下载 Cypress 二进制文件失败
- android - 当我离开片段并再次输入时,错误片段未附加到活动
- javascript - keyup 搜索功能也可以获取输入值