In PowerShell, & "C:\Program Files\Java\jre-9.0.1\bin\jjs.exe" --language=es6
gives me access to the Nashorn interpreter for ES6. I want to create an alias for exactly this. How can I create an alias to start this process with the desired command-line option?
Asked
Active
Viewed 697 times
0

Alan
- 9,410
- 15
- 20
-
2Aliases don't support that. Define a function instead: `function nashorn { & "C:\Program Files\Java\jre-9.0.1\bin\jjs.exe" --language=es6 }` – Mathias R. Jessen Dec 30 '17 at 20:49
-
@MathiasR.Jessen Thanks; I was aware of this solution. Can you say simply why this is beyond the scope of aliases? (I'm pretty new to PowerShell.) Thanks. – Alan Dec 30 '17 at 21:22
1 Answers
0
Putting Mathias's comment as an answer. You should create it as a function and finally you can call the function wherever you need it just by the name.
function call-nashorn
{
& "C:\Program Files\Java\jre-9.0.1\bin\jjs.exe" --language=es6
}
call-nashorn

Ranadip Dutta
- 8,857
- 3
- 29
- 45