我只是好奇是否可以在命令提示符下创建一个默认目录。我在 cmd 中运行我的 java 程序,当我在新会话期间打开它时,我总是希望它在特定文件夹中启动,因此我不必使用 cd 进程手动导航到该文件夹。
我认为我让这个过程变得比它需要的更困难。谁能告诉我如何创建目录的批处理文件快捷方式?
我只是好奇是否可以在命令提示符下创建一个默认目录。我在 cmd 中运行我的 java 程序,当我在新会话期间打开它时,我总是希望它在特定文件夹中启动,因此我不必使用 cd 进程手动导航到该文件夹。
我认为我让这个过程变得比它需要的更困难。谁能告诉我如何创建目录的批处理文件快捷方式?
I'm guessing you want to easily run your Java programs without always having to type
"C:\Program Files\Java\jdk#.#.###\bin\java.exe" ...
I thought the same and so did it. You can add the folder above (your jdk) to be included in cmd default paths by including it in the %PATH% system/environment variable, this is done in Windows 7 by opening Computer -> System Properties -> Advanced System Settings -> Environment Variables, under System variables choose the one called PATH and edit, add a semicolon to declare the end of the last path and copy the path of your JRE/JDK in to look something like:
...;...;...;C:\Program Files\Java\jdk1.7.0_25\bin\
To test it open up Command Prompt and type set
to view all declared variables, PATH should now include your java path, meaning you can simply mention java
or javac
now.
您可以将长路径名存储在变量中,并将该变量用作 cd 的参数。
C:\> setx go "C:\Users\Edisson\Documents\sampdb\Support"
#restart session
C:\> cd %go%
C:\Users\Edisson\Documents\sampdb\Support\>