How do I "alias" the execution of a .jar file as a global command?
Create a batch file with the following:
java -jar C:\Users\Jacob\swagger-codegen-cli.jar %*
The %*
portion tells the batch script to pass all of the parameters it receives to the new command.
If there are no other executables in the same directory as the .jar
file, you can safely save the batch file there as swagger-codegen.bat
and then add it to your PATH
variable.
If there are other executables in the same directory, make sure they don't conflict with any other commands that might be reachable through your PATH
variable.
The DOSKEY
command can create an alias in cmd
:
doskey swagger-codegen=java -jar C:\Users\Jacob\swagger-codegen-cli.jar
If you need this to be defined whenever cmd
starts, you can define it in an initialisation file.