安装JDK
首先下载jdk进官网下载jdk, jdk-8u231-windows-x64
截止20191209,最新JAVA版本为JAVE SE 13。考虑一些兼容性问题,建议使用JAVE SE 8版本
下载完成后,一键安装即可
安装后会有两个jre,一个jdk内部的,和jdk外部的
一个jre文件在JDK的外部,一个jre文件在JDK内部,这就是所谓的专用JRE和公用JRE
-
专用 JRE
安装 JDK 时,会安装一个专用 JRE,并且您可以选择安装一个公共副本。需要专用 JRE 才能运行 JDK 中包含的工具。专用 JRE 没有注册表设置,并且完全包含在仅对 JDK 已知的 Java 目录位置(通常位于 C:\Program Files\Java\jdk1.8.0_231\jre)中。 -
公共 JRE
可由其他 Java 应用程序使用,并且包含在 JDK 外部(通常位于C:\Program Files\Java\jre1.8.0_231)。公共 JRE 会注册到 Windows 注册表(位于 HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft)中。公共 JRE 可以使用“添加/删除程序”进行删除,并且还会注册到浏览器。
安装完成后,打开cmd, 输入java或者java -version来确认安装是否正常
C:\Users\arvin.chen>java
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
where options include:
-d32 use a 32-bit data model if available
-d64 use a 64-bit data model if available
-server to select the "server" VM
The default VM is server.
-cp <class search path of directories and zip/jar files>
-classpath <class search path of directories and zip/jar files>
A ; separated list of directories, JAR archives,
and ZIP archives to search for class files.
-D<name>=<value>
set a system property
-verbose:[class|gc|jni]
enable verbose output
-version print product version and exit
-version:<value>
Warning: this feature is deprecated and will be removed
in a future release.
require the specified version to run
-showversion print product version and continue
-jre-restrict-search | -no-jre-restrict-search
Warning: this feature is deprecated and will be removed
in a future release.
include/exclude user private JREs in the version search
-? -help print this help message
-X print help on non-standard options
-ea[:<packagename>...|:<classname>]
-enableassertions[:<packagename>...|:<classname>]
enable assertions with specified granularity
-da[:<packagename>...|:<classname>]
-disableassertions[:<packagename>...|:<classname>]
disable assertions with specified granularity
-esa | -enablesystemassertions
enable system assertions
-dsa | -disablesystemassertions
disable system assertions
-agentlib:<libname>[=<options>]
load native agent library <libname>, e.g. -agentlib:hprof
see also, -agentlib:jdwp=help and -agentlib:hprof=help
-agentpath:<pathname>[=<options>]
load native agent library by full pathname
-javaagent:<jarpath>[=<options>]
load Java programming language agent, see java.lang.instrument
-splash:<imagepath>
show splash screen with specified image
See http://www.oracle.com/technetwork/java/javase/documentation/index.html for more details.
C:\Users\arvin.chen>java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)
配置环境变量
部分程序需要环境变量JAVA_HOME与classpath,建议安装完后进行配置。
JAVA_HOME: C:\Program Files\Java\jdk1.8.0_231(java安装目录)
classpath:.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
然后新建变量名:classpath 变量值:.;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar点确定
变量中找到名为“Path”的变量并双击,添加 %JAVA_HOME%\bin