【发布时间】:2021-05-29 06:19:24
【问题描述】:
我使用的是 Windows 10,但无法使用 PowerShell 为 Java 平台设置别名。
这适用于 Git Bash:
alias mytest='java -Xms1g -Xmx4g -cp D:/mypath/myfile.jar myfile.myapp'
当我在 Git Bash 提示符中输入 mytest 时,它会返回:
myfile [v11.3.0]
Usage:
java ...
我可以在 Git Bash 提示符下使用别名毫无问题地运行它。
我也在尝试学习如何在 PowerShell 中执行此操作,以下是我的尝试和错误:
Set-Alias -Name "mytest" -Value "java -Xms1g -Xmx4g -cp D:\mypath\myfile.jar myfile.myapp" -Description "An alias to for mytest"
当我在 PowerShell 提示符中输入 mytest 时,它会返回此错误:
mytest : The term 'D:\mypath\myfile.jar myfile.myapp' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ mytest
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (D:\mypath\myfile.jar myfile.myapp:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我还尝试了以下方法,基于How do I set an alias for a specific command in Powershell?,它返回相同的错误:
Function mytest { java -Xms1g -Xmx4g -cp "D:\mypath\myfile.jar myfile.myapp" $args }
【问题讨论】:
标签: powershell windows-10