首页 Tomcat教程JDK介绍安装

Java介绍,基础入门

Tomcat经典入门教程

运维派隶属马哥教育旗下专业运维社区,是国内成立最早的IT运维技术社区,欢迎关注公众号:yunweipai
领取学习更多免费Linux云计算、Python、Docker、K8s教程关注公众号:马哥linux运维

JDK
JDK和JRE

JDK介绍安装插图

JRE:它是Java Runtime Environment缩写,指Java运行时环境, 包含 JVM + Java核心类库

JDK:它是Java Development Kit,即 Java 语言的软件开发工具包。

JDK介绍安装插图(1)
JDK介绍安装插图(2)

JDK也就是常说的J2SE,在1999年,正式发布了Java第二代平台,发布了三个版本:
J2SE:标准版,适用于桌面平台
J2EE:企业版,java在企业级开发所有规范的总和,共有13个大的规范
J2ME:微型版,适用于移动、无线、机顶盒等设备环境

2005年,Java的版本又更名为JavaSE、JavaEE、JavaME

Servlet、Jsp都包含在JavaEE规范中

JDK7、JDK8、JDK11是LTS(Long Term Suppot)

版本 项目名称 发行日期
JDK 1.1.4 Sparkler(宝石) 1997-09-12
JDK 1.1.5 Pumpkin(南瓜) 1997-12-13
JDK 1.1.6 Abigail(阿比盖尔–女子名) 1998-04-24
JDK 1.1.7 Brutus(布鲁图–古罗马政治家和将军) 1998-09-28
JDK 1.1.8 Chelsea(切尔西–城市名) 1999-04-08
J2SE 1.2 Playground(运动场) 1998-12-04
J2SE 1.2.1 none(无) 1999-03-30
J2SE 1.2.2 Cricket(蟋蟀) 1999-07-08
J2SE 1.3 Kestrel(美洲红隼) 2000-05-08
J2SE 1.3.1 Ladybird(瓢虫) 2001-05-17
J2SE 1.4.0 Merlin(灰背隼) 2002-02-13
J2SE 1.4.1 grasshopper(蚱蜢) 2002-09-16
J2SE 1.4.2 Mantis(螳螂) 2003-06-26
Java SE 5.0 (1.5.0) Tiger(老虎) 2004-09-30
Java SE 6.0 (1.6.0) Mustang(野马) 2006-04
Java SE 7.0 (1.7.0) Dolphin(海豚) 2011-07-28
Java SE 8.0 (1.8.0) Spider(蜘蛛) 2014-03-18
Java SE 9 2017-09-21
Java SE 10 2018-03-14 [3]

JDK协议基于 JRL(JavaResearch License)协议

OpenJDK

OpenJDK是Sun公司采用GPL v2协议发布的JDK开源版本,于2009年正式发布。

JDK介绍安装插图(3)

官方网站:https://openjdk.java.net/projects/jdk6/

OpenJDK 7是基于JDK7的beta版开发,但为了也将Java SE 6开源,从OpenJDK7的b20构建反向分支开发,从中剥离了不符合Java SE 6规范的代码,发布OpenJDK 6。所以OpenJDK6和JDK6没什么关系。

OpenJDK使用GPL v2可以用于商业用途。

安装 openjdk

  • 在Centos中,可以使用 yum 仓库安装 openjdk
[root@centos8 ~]#dnf list "*jdk*"
BaseOS                                                                        218 kB/s | 3.9 kB     00:00    
AppStream                                                                     207 kB/s | 4.3 kB     00:00    
EPEL                                                                           27 kB/s | 5.3 kB     00:00    
EPEL                                                                          6.9 MB/s | 5.6 MB     00:00    
extras                                                                        6.8 kB/s | 1.5 kB     00:00    
Available Packages
copy-jdk-configs.noarch                                      3.7-1.el8                               AppStream
java-1.8.0-openjdk.x86_64                                    1:1.8.0.232.b09-0.el8_0                 AppStream
java-1.8.0-openjdk-accessibility.x86_64                      1:1.8.0.232.b09-0.el8_0                 AppStream
java-1.8.0-openjdk-demo.x86_64                               1:1.8.0.232.b09-0.el8_0                 AppStream
java-1.8.0-openjdk-devel.x86_64                              1:1.8.0.232.b09-0.el8_0                 AppStream
java-1.8.0-openjdk-headless.x86_64                           1:1.8.0.232.b09-0.el8_0                 AppStream
java-1.8.0-openjdk-javadoc.noarch                            1:1.8.0.232.b09-0.el8_0                 AppStream
java-1.8.0-openjdk-javadoc-zip.noarch                        1:1.8.0.232.b09-0.el8_0                 AppStream
java-1.8.0-openjdk-src.x86_64                                1:1.8.0.232.b09-0.el8_0                 AppStream
java-11-openjdk.x86_64                                       1:11.0.5.10-0.el8_0                     AppStream
java-11-openjdk-demo.x86_64                                  1:11.0.5.10-0.el8_0                     AppStream
java-11-openjdk-devel.x86_64                                 1:11.0.5.10-0.el8_0                     AppStream
java-11-openjdk-headless.x86_64                              1:11.0.5.10-0.el8_0                     AppStream
java-11-openjdk-javadoc.x86_64                               1:11.0.5.10-0.el8_0                     AppStream
java-11-openjdk-javadoc-zip.x86_64                           1:11.0.5.10-0.el8_0                     AppStream
java-11-openjdk-jmods.x86_64                                 1:11.0.5.10-0.el8_0                     AppStream
java-11-openjdk-src.x86_64                                   1:11.0.5.10-0.el8_0                     AppStream
java-latest-openjdk.x86_64                                   1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-demo.x86_64                              1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-demo-slowdebug.x86_64                    1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-devel.x86_64                             1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-devel-slowdebug.x86_64                   1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-headless.x86_64                          1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-headless-slowdebug.x86_64                1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-javadoc.x86_64                           1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-javadoc-zip.x86_64                       1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-jmods.x86_64                             1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-jmods-slowdebug.x86_64                   1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-slowdebug.x86_64                         1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-src.x86_64                               1:13.0.2.8-1.rolling.el8                epel     
java-latest-openjdk-src-slowdebug.x86_64                     1:13.0.2.8-1.rolling.el8                epel

[root@centos8 ~]#dnf -y install java-1.8.0-openjdk.x86_64

[root@centos8 ~]#java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK 64-Bit Server VM (build 25.232-b09, mixed mode)

# java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b04)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)

[root@centos8 ~]#which java
/usr/bin/java
[root@centos8 ~]#ll /usr/bin/java
lrwxrwxrwx 1 root root 22 Feb  8 20:03 /usr/bin/java -> /etc/alternatives/java

[root@centos8 ~]#ll /etc/alternatives/java
lrwxrwxrwx 1 root root 73 Feb  8 20:03 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el8_0.x86_64/jre/bin/java

[root@centos8 ~]#rpm -qf /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-0.el8_0.x86_64/jre/bin/java
java-1.8.0-openjdk-headless-1.8.0.232.b09-0.el8_0.x86_64
  • ubuntu 安装 openjdk
[root@ubuntu1804 ~]#apt update
[root@ubuntu1804 ~]#apt install openjdk-8-jdk -y
[root@ubuntu1804 ~]#java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (build 1.8.0_242-8u242-b08-0ubuntu3~18.04-b08)
OpenJDK 64-Bit Server VM (build 25.242-b08, mixed mode)
安装oracle官方 JDK
  • 使用Oracle官网的JDK 8的rpm安装
#官网下载:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
[root@centos8 ~]#ls -lh jdk-8u241-linux-x64.rpm
-rw-r--r-- 1 root root 171M Feb  8 18:29 jdk-8u241-linux-x64.rpm

#安装jdk,无相关依赖包
[root@centos8 ~]#dnf -y install jdk-8u241-linux-x64.rpm
[root@centos8 ~]#java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

#初始化环境变量
[root@centos8 ~]#vim /etc/profile.d/jdk.sh
[root@centos8 ~]#cat /etc/profile.d/jdk.sh
export JAVA_HOME=/usr/java/default
export JRE_HOME=JAVA_HOME/jre
export CLASSPATH=JAVA_HOME/lib/:JRE_HOME/lib/
export PATH=JAVA_HOME/bin:$PATH
[root@centos8 ~]#. /etc/profile.d/jdk.sh

#查看jdk信息
[root@centos8 ~]#which java
/usr/bin/java
[root@centos8 ~]#ll /usr/bin/java
lrwxrwxrwx 1 root root 22 Feb  8 18:35 /usr/bin/java -> /etc/alternatives/java
[root@centos8 ~]#ll /etc/alternatives/java
lrwxrwxrwx 1 root root 41 Feb  8 18:35 /etc/alternatives/java -> /usr/java/jdk1.8.0_241-amd64/jre/bin/java

[root@centos8 ~]#rpm -q --scripts jdk-8u241-linux-x64.rpm

#查看到安装目录为/user/java下
[root@centos8 ~]#rpm -ql jdk-8u241-linux-x64.rpm |less
warning: jdk-8u241-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
/usr
/usr/java
/usr/java/jdk1.8.0_241-amd64
/usr/java/jdk1.8.0_241-amd64/.java
/usr/java/jdk1.8.0_241-amd64/.java/.systemPrefs
/usr/java/jdk1.8.0_241-amd64/.java/.systemPrefs/.system.lock
/usr/java/jdk1.8.0_241-amd64/.java/.systemPrefs/.systemRootModFile
/usr/java/jdk1.8.0_241-amd64/.java/init.d
......

[root@centos8 ~]#ll /usr/java/
total 0
lrwxrwxrwx 1 root root  16 Feb  8 18:35 default -> /usr/java/latest
drwxr-xr-x 8 root root 258 Feb  8 18:35 jdk1.8.0_241-amd64
lrwxrwxrwx 1 root root  28 Feb  8 18:35 latest -> /usr/java/jdk1.8.0_241-amd64
  • 安装oracle官网的二进制文件
#下载安装包:https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
[root@centos8 ~]#tar xvf jdk-8u241-linux-x64.tar.gz  -C /usr/local/
[root@centos8 ~]#cd  /usr/local/
[root@centos8 ~]#ln -s jdk1.8.0_241/ jdk

#初始化环境变量
[root@centos8 ~]#vim /etc/profile.d/jdk.sh
[root@centos8 ~]#cat /etc/profile.d/jdk.sh 
export JAVA_HOME=/usr/local/jdk
export JRE_HOME=JAVA_HOME/jre
export CLASSPATH=JAVA_HOME/lib/:JRE_HOME/lib/
export PATH=PATH:$JAVA_HOME/bin
[root@centos8 ~]#.  /etc/profile.d/jdk.sh

#验证安装
[root@centos8 ~]#java -version
java version "1.8.0_241"
Java(TM) SE Runtime Environment (build 1.8.0_241-b07)
Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)
[root@centos8 ~]#which java
/usr/local/jdk/bin/java

本文链接:http://www.yunweipai.com/35109.html

Java介绍,基础入门

Tomcat经典入门教程

网友评论comments

发表评论

邮箱地址不会被公开。

暂无评论

Copyright © 2012-2021 YUNWEIPAI.COM - 运维派 京ICP备16064699号-6
扫二维码
扫二维码
返回顶部