如何在Windows上安装OpenJDK 11? [英] How to install OpenJDK 11 on Windows?
问题描述
过去,Oracle曾为Windows发布可执行的安装程序,该程序将:
In the past, Oracle used to publish an executable installers for Windows that would:
- 解压缩文件
- 添加注册表项以指示安装的版本和路径
- 将JRE添加到系统PATH
- 在Windows中注册卸载程序.
从Java 11开始,Oracle的Java免费版本( Oracle OpenJDK )似乎没有包括安装程序.这只是一个包含二进制文件的zip文件.
As of Java 11, the Oracle's free version of Java (Oracle OpenJDK) doesn't seem to include an installer. It is just a zip file containing the binaries.
鉴于前面提到的集成不再存在,我们应该如何在Windows上安装OpenJDK 11?他们不是必要的吗?
How are we supposed to install OpenJDK 11 on Windows seeing as the aforementioned integrations are no longer there? Aren't they necessary?
推荐答案
-
将zip文件提取到一个文件夹中,例如
C:\Program Files\Java\
,它将创建一个jdk-11
文件夹(其中bin文件夹是直接子文件夹).您可能需要管理员权限才能将zip文件解压缩到该位置.
Extract the zip file into a folder, e.g.
C:\Program Files\Java\
and it will create ajdk-11
folder (where the bin folder is a direct sub-folder). You may need Administrator privileges to extract the zip file to this location.
设置路径:
- 选择控制面板,然后选择系统.
- 点击高级",然后点击环境变量".
- 将JDK安装的bin文件夹的位置添加到系统变量"中的PATH变量中.
- 以下是PATH变量的典型值:
C:\WINDOWS\system32;C:\WINDOWS;"C:\Program Files\Java\jdk-11\bin"
- Select Control Panel and then System.
- Click Advanced and then Environment Variables.
- Add the location of the bin folder of the JDK installation to the PATH variable in System Variables.
- The following is a typical value for the PATH variable:
C:\WINDOWS\system32;C:\WINDOWS;"C:\Program Files\Java\jdk-11\bin"
设置JAVA_HOME:
Set JAVA_HOME:
- 在系统变量"下,单击新建".
- 输入变量名称JAVA_HOME.
- 输入变量值作为JDK的安装路径(不包含
bin
子文件夹). - 单击确定".
- 点击应用更改".
- Under System Variables, click New.
- Enter the variable name as JAVA_HOME.
- Enter the variable value as the installation path of the JDK (without the
bin
sub-folder). - Click OK.
- Click Apply Changes.
您已设置好.
要查看它是否有效,请打开命令提示符,然后键入java -version
并查看它是否会打印新安装的JDK.
To see if it worked, open up the Command Prompt and type java -version
and see if it prints your newly installed JDK.
如果要卸载-只需撤消上述步骤即可.
If you want to uninstall - just undo the above steps.
注意:您还可以将JAVA_HOME
指向JDK安装目录,然后将PATH
变量设置为%JAVA_HOME%\bin
.因此,当您想更改JDK时,只需更改JAVA_HOME
变量,并保留PATH
不变.
Note: You can also point JAVA_HOME
to the folder of your JDK installations and then set the PATH
variable to %JAVA_HOME%\bin
. So when you want to change the JDK you change only the JAVA_HOME
variable and leave PATH
as it is.
这篇关于如何在Windows上安装OpenJDK 11?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!