I am using Windows 10 and having trouble setting an alias to a Java platform using PowerShell.
This works in Git Bash:
alias mytest='java -Xms1g -Xmx4g -cp D:/mypath/myfile.jar myfile.myapp'
And when I type mytest
into the Git Bash prompt, it returns:
myfile [v11.3.0]
Usage:
java ...
And I can run it without issue in the Git Bash prompt using the alias.
I am trying to learn how to do this in PowerShell also, and here are my attempts and errors:
Set-Alias -Name "mytest" -Value "java -Xms1g -Xmx4g -cp D:\mypath\myfile.jar myfile.myapp" -Description "An alias to for mytest"
And when I enter mytest
in the PowerShell prompt, it returns this error:
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
I also tried the following, based on How do I set an alias for a specific command in Powershell?, and it returns the same error:
Function mytest { java -Xms1g -Xmx4g -cp "D:\mypath\myfile.jar myfile.myapp" $args }