JDK安装与配置

JDK安装与配置

𝓓𝓸𝓷 Lv6

学的到东西的事情是锻炼,学不到的是磨练。

一、下载JDK

https://www.oracle.com/java/technologies/downloads/#java8-windows
https://www.oracle.com/java/technologies/downloads/#java8-linux

image-20240714084756722

image-20240714084308915

二、Windows安装JDK
1.安装

mark

mark

mark

mark

mark

mark

mark

mark

mark

2.设置环境变量
  • 设置JAVA_HOME环境变量

JAVA_HOME=C:\Java\jdk1.8.0_91

mark

  • 设置Path环境变量

将C:\Java\jdk1.8.0_91\bin 添加进环境变量中,或者: %JAVA_HOME%\bin

mark

  • 设置CLASSPATH环境变量

.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar

mark

3.测试JAVA

mark

4.安装库源文件和文档库

源文件在JDK中以一个压缩文件src.zip的形式发布,必须将其解压才能访问源代码:

  • JAVA_HOME目录下自带有src.zip
  • 在JAVA_HOME目录下新建src文件夹
  • cd到这个文件夹,执行命令jar -xvf ..\src.zip下载src.zip文件,将其放在src文件夹中
三、Linux安装JDK
1.安装
1
2
3
4
5
6
7
8
[root@server ~]# tar xvf jdk-8u411-linux-x64.tar.gz -C /usr/local/

[root@server ~]# cd /usr/local/
[root@server local]# ln -s jdk1.8.0_411 jdk

[root@server local]# ll |grep jdk
lrwxrwxrwx 1 root root 12 Jul 14 08:58 jdk -> jdk1.8.0_411
drwxr-xr-x 8 root root 4096 Jul 14 08:53 jdk1.8.0_411
2.配置环境变量
1
2
3
4
5
6
7
8
9
10
11
12
[root@server local]# vim /etc/profile

export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

[root@server local]# tail -3 /etc/profile
export JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

[root@server local]# source /etc/profile
3.校验安装
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
[root@server local]# java -version
java version "1.8.0_411"
Java(TM) SE Runtime Environment (build 1.8.0_411-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.411-b09, mixed mode)

[root@server local]# javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files and annotation processors
-cp <path> Specify where to find user class files and annotation processors
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-endorseddirs <dirs> Override location of endorsed standards path
-proc:{none,only,full} Control whether annotation processing and/or compilation is done.
-processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
-processorpath <path> Specify where to find annotation processors
-parameters Generate metadata for reflection on method parameters
-d <directory> Specify where to place generated class files
-s <directory> Specify where to place generated source files
-h <directory> Specify where to place generated native header files
-implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-profile <profile> Check that API used is available in the specified profile
-version Version information
-help Print a synopsis of standard options
-Akey[=value] Options to pass to annotation processors
-X Print a synopsis of nonstandard options
-J<flag> Pass <flag> directly to the runtime system
-Werror Terminate compilation if warnings occur
@<filename> Read options and filenames from file

  • Title: JDK安装与配置
  • Author: 𝓓𝓸𝓷
  • Created at : 2024-07-15 09:20:37
  • Updated at : 2024-07-20 05:15:41
  • Link: https://www.zhangdong.me/jdk-installation.html
  • License: This work is licensed under CC BY-NC-SA 4.0.
评论