且构网

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

如何***地在windows中设置java的路径

更新时间:2023-01-14 22:14:55

安装新版本的 JRE 时,此路径 C:\Program Files (x86)\Common Files\Oracle\Java似乎使用与新 JRE 版本相对应的可执行文件进行了更新.问题是这将是 JRE 而不是 JDK.因此,依赖 JDK(例如 IDE)的程序将无法启动.

When a new version of JRE is installed, this path C:\Program Files (x86)\Common Files\Oracle\Java appears to be updated with executables corresponding to the new JRE version. The problem is this would be JRE and not JDK. So, programs that depend on JDK (IDE for example) will fail to launch.

这是我如何让它始终如一地工作

  1. 我总是在用户变量中有一个环境变量(进入控制面板的系统环境变量 -> 系统 -> 高级系统设置 -> 环境变量 -> 用户变量)-- JAVA_HOME 指向 JDK 主页.并将 %JAVA_HOME%\bin 添加到 PATH 环境变量中.
  2. 有趣的是,我从 System 中的 Path 环境变量中删除了条目 C:\Program Files (x86)\Common Files\Oracle\Java\javapath环境变量(控制面板 -> 系统 -> 高级系统设置 -> 环境变量 -> 系统变量).
  1. I always have an environment variable in User Variables (System Environment Variables by going to Control Panel -> System -> Advanced System Settings -> Environment Variables -> User Variables) -- JAVA_HOME pointing to the JDK Home. And add %JAVA_HOME%\bin to the PATH environment variable.
  2. Interestingly, I remove the entry C:\Program Files (x86)\Common Files\Oracle\Java\javapath from the Path environment variable in System Environment Variables (Control Panel -> System -> Advanced System Settings -> Environment Variables -> System Variables).

自 2020 年 8 月起适用于 Windows 10 (1903)、Java 8u251.:)

This works as of Aug 2020 for Windows 10 (1903), Java 8u251. :)