且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Windows上设置Java路径?

更新时间:2023-01-14 22:18:45

除了设置 JAVA_HOME 系统变量外,您还需要设置 Path 变量,因为 Path 是操作系统用于从终端窗口中找到所需可执行文件的系统变量.

Apart from setting the JAVA_HOME system variable you need to set the Path variable as well because the Path is the system variable that your Operating system uses to locate the needed executable from the terminal window.

因此,设置路径变量的步骤如下:

So for setting the Path Variable proceed as follows:

  • 右键单击我的电脑"图标->属性->高级系统设置->环境变量
  • 现在,在系统变量下滚动到 Path 变量
  • 选择路径"变量,然后单击编辑"按钮
  • 现在在Variable值的末尾添加%JAVA_HOME%\ bin,将此值与列表中的现有值分隔开;例如xxxxx;%JAVA_HOME%\ bin;

请注意,在执行上述步骤之前,还请检查是否正确设置了JAVA_HOME变量.为此,请转到命令提示符并键入 echo%JAVA_HOME%.如果设置正确,它将为您提供jdk的路径.

Note that before following the above steps also check if your JAVA_HOME variable is properly set. For doing this go to command prompt and type echo %JAVA_HOME%. If it is properly set then it will give you the path of your jdk.

注意: :有时会同时设置 Path JAVA_HOME 变量,但仍然存在不起作用.为避免这种情况,请以管理员身份运行命令提示符.

NOTE: Sometimes it happens that both the Path and JAVA_HOME variables are set properly but still things are not working.To avoid this run the command prompt as administrator.