java配置环境变量Path和classpath

path:

1.环境变量有很多,其中最常见的环境变量名为Path。

2.Path是系统指定的可执行文件的路径。例如:在CMD窗口输入.exe程序名,系统会在Path路径找这个文件。

3.Path路径不止一个,优先搜索最靠前的路径下的文件。搜索成功后,停止;否则,继续找下一个路径。

如:下列为作者机器上的Path路径:

C:\Users\Leon>echo %path%

C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Users\Leon\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\JetBrains\PyCharm 2018.3.2\bin;

4.在CMD中设置临时环境变量:

  set path=%path%;C:\Java\bin

临时变量只有在当前CMD窗口中才有效,其他窗口无效~

5.在系统的窗口下设置环境变量是永久生效的。

6.把C:\Java\bin置顶,可以首先在这个文件中查找程序。

结果为:

C:\Users\Leon>echo %path%

C:\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Users\Leon\AppData\Local\Microsoft\WindowsApps;;C:\Program Files\JetBrains\PyCharm 2018.3.2\bin;

classpath: