英文:
How can I setup a custom run setup for path(for code runner extension)?
问题
当我运行code runner(使用java)时,它会要求javac。
所以我必须设置一个路径,但是在我使用的计算机上不允许永久路径,所以我一直在使用:
> set path=C:\Program Files\Java\jdk1.8.0_241\bin 对于cmd
或者
> $env:Path = "C:\Program Files\Java\jdk1.8.0_241\bin"; 对于powershell
我使用VS Code的在终端中运行功能,这样它会给我生成.class文件(是的,我知道如果我按F5运行它,不会有问题,但我不喜欢终端上的文本混乱 XD)。
所以问题是,我如何创建一个自定义命令来设置路径(无论是在启动时还是每次运行时)?
或者,我是否需要修改默认设置?(如果是这样,文件位置在哪里)?
英文:
So when I run code runner (using java) it asks for javac
so I have to set up a path, but on the computer that I'm using doesn't allow permanent path so, I've been using:
> set path=C:\Program Files\Java\jdk1.8.0_241\bin for cmd
or
> $env:Path = "C:\Program Files\Java\jdk1.8.0_241\bin"; for powershell
I'm using the VS Code run in terminal so it gives me the .class (yes I know that if I run it in F5 it has no problems but I don't like the text mess on the terminal XD)
So the question is how can I make a custom command so it sets up the path (be it at startup or every time)
Or, Do I have to modify the default settings? (if so where is the file location)
答案1
得分: 0
设置Windows上的默认路径,请转到控制面板,系统,高级系统设置,环境变量。
英文:
To set the default path on Windows, go to Control Panel, System, Advanced System Settings, Environment Variables.
答案2
得分: 0
对于命令提示符(cmd):
- 打开命令提示符并运行以下命令:
reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun ^ /t REG_EXPAND_SZ /d "%USERPROFILE%\init.cmd" /f
- 在你的用户文件夹中(例如:C:\Users\用户名)创建一个名为 "init.cmd" 的文件,然后你可以在该文件中设置你想要在启动命令提示符时自动运行的命令。
英文:
For cmd:
1.open a cmd and run the commands:
reg add "HKCU\Software\Microsoft\Command Processor" /v AutoRun ^ /t REG_EXPAND_SZ /d "%"USERPROFILE"%\init.cmd" /f
2.create a file in your USERPROFILE(likes:C:\Users\UserName) folder named "init.cmd" and then you can set the commands which you want to run automatically when the Command Prompt is launched.
专注分享java语言的经验与见解,让所有开发者获益!
评论