Linux CentOS 七 下jdk安装

By admin in 美高梅手机版4858 on 2019年4月23日

一.在/usr/目录下创办java目录

壹.在/usr/目录下开创java目录

1.在/usr/local下创建java目录

[root@localhost local]# mkdir java
[root@localhost local]# cd java

出于各Linux开荒厂家的区别,因而不一致开荒厂商的Linux版本操作细节也不等同,今日就来讲一下CentOS下JDK的设置:
主意一:手动解压JDK的压缩包,然后设置景况变量
1.在/usr/目录下成立java目录
[root@localhost ~]# mkdir/usr/java
[root@localhost ~]# cd /usr/java
二.下载jdk,然后解压
[root@localhost java]# curl -O
http://download.Oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz
[root@localhost java]# tar -zxvf jdk-7u79-linux-x64.tar.gz
叁.设置处境变量
[root@localhost java]# vi /etc/profile
在profile中增加如下内容:

[root@localhost ~]# mkdir /usr/java
[root@localhost ~]# cd /usr/java

[root@localhost ~]# mkdir /usr/java
[root@localhost ~]# cd /usr/java

二.导入jdk.tar.gz (此处是本土已有tar包)

[root@localhost java]# tar -zxvf jdk-7u79-linux-x64.tar.gz

set java environment

JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效:
[root@localhost java]# source /etc/profile
4.验证JDK有效性
[root@localhost java]# java -version
java version “1.7.0_79”
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
方法二:用yum安装JDK
壹.查看yum库中都有怎么样jdk版本(一时只发现了openjdk)
[root@localhost ~]# yum search java|grep jdk
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
Linux CentOS 七 下jdk安装。java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk.x86_64 : The Mozilla LDAP Java SDK
2.精选版本,进行安装
//选取1.7版本实行安装
[root@localhost ~]# yum install java-1.7.0-openjdk
//安装完之后,暗中认可的设置目录是在:
/usr/lib/jvm/java-1.柒.0-openjdk-一.七.0.75.x86_64
叁.装置境况变量
[root@localhost ~]# vi /etc/profile
在profile文件中加多如下内容

二.复制jdk一.捌到java目录下,解压到当前目录

二.复制jdk1.八到java目录下,解压到当前目录

三.设置情形变量

[root@localhost java]# vi /etc/profile

进入文件后,加多遇到变量,类似于windows系统增添系统变量.增多内容如下

注:linux 系统的碰着变量大部分都以修改 profile 文件。
JAVA_HOME=/usr/local/java/jdk1.7.0_76
JRE_HOME=/usr/local/java/jdk1.7.0_76/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

set java environment

JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效
[root@localhost java]# source /etc/profile
四.验证(同上1形式)
方法三:用rpm安装JDK
一.下载rpm安装文件
[root@localhost ~]$ curl -O
http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm
二.行使rpm命令安装
[root@localhost ~]# rpm -ivh jdk-7u79-linux-x64.rpm
3.安装意况变量
[root@localhost java]# vi /etc/profile
在开拓的profile文件中增加如下内容

[root@localhost java]# tar -zxvf jdk-8u131-linux-x64.tar.gz

[root@localhost java]# tar -zxvf jdk-8u131-linux-x64.tar.gz

肆.刷新系统铺排,是条件生效

[root@localhost java]# source /etc/profile

set java environment

JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效
[root@localhost java]# source /etc/profile
四.验证(同上1主意)
注:和yum安装类似,不用安装情形变量就足以运作java命令。rpm安装格局暗中认可会把jdk安装到/usr/java/jdk一.7.0_7玖,然后通过三层链接,链接到/usr/bin,具体链接如下:
[root@localhost ~]# cd /bin
[root@localhost bin]# ll|grep java
lrwxrwxrwx. 1 root root 25 Mar 28 11:24 jar
->/usr/java/default/bin/jar
lrwxrwxrwx. 1 root root 26 Mar 28 11:24 java ->
/usr/java/default/bin/java
lrwxrwxrwx. 1 root root 27 Mar 28 11:24 javac
->/usr/java/default/bin/javac
lrwxrwxrwx. 1 root root 29 Mar 28 11:24 javadoc
->/usr/java/default/bin/javadoc
lrwxrwxrwx. 1 root root 28 Mar 28 11:24 javaws
->/usr/java/default/bin/javaws
lrwxrwxrwx. 1 root root 30 Mar 28 11:24 jcontrol
->/usr/java/default/bin/jcontrol
[root@localhost bin]# cd /usr/java/
[root@localhost java]# ll
total 4
lrwxrwxrwx. 1 root root 16 Mar 28 11:24 default-> /usr/java/latest
drwxr-xr-x. 8 root root 4096 Mar 28 11:24 jdk1.7.0_79
lrwxrwxrwx. 1 root root 21 Mar 28 11:24 latest ->
/usr/java/jdk1.7.0_79
方法四:Ubuntu 上使用apt-get安装JDK
1.查看apt库都有啥jdk版本
root@linuxidc:~# apt-cache search java|grep jdk
default-jdk – Standard Java or Java compatible Development Kit
default-jdk-doc – Standard Java or Java compatible Development Kit
(documentation)
gcj-4.6-jdk – gcj and classpath development tools for Java(TM)
gcj-jdk – gcj and classpath development tools for Java(TM)
openjdk-6-dbg – Java runtime based on OpenJDK (debugging symbols)
美高梅手机版4858,openjdk-6-demo – Java runtime based on OpenJDK (demos and examples)
openjdk-6-doc – OpenJDK Development Kit (JDK) documentation
openjdk-6-jdk – OpenJDK Development Kit (JDK)
openjdk-6-jre-lib – OpenJDK Java runtime (architecture independent
libraries)
openjdk-6-source – OpenJDK Development Kit (JDK) source files
openjdk-7-dbg – Java runtime based on OpenJDK (debugging symbols)
openjdk-7-demo – Java runtime based on OpenJDK (demos and examples)
openjdk-7-doc – OpenJDK Development Kit (JDK) documentation
openjdk-7-jdk – OpenJDK Development Kit (JDK)
openjdk-7-source – OpenJDK Development Kit (JDK) source files
uwsgi-plugin-jvm-openjdk-6 – Java plugin for uWSGI (OpenJDK 6)
uwsgi-plugin-jwsgi-openjdk-6 – JWSGI plugin for uWSGI (OpenJDK 6)
openjdk-6-jre – OpenJDK Java runtime, using Hotspot JIT
openjdk-6-jre-headless – OpenJDK Java runtime, using Hotspot JIT
(headless)
openjdk-7-jre – OpenJDK Java runtime, using Hotspot JIT
openjdk-7-jre-headless – OpenJDK Java runtime, using Hotspot JIT
(headless)
openjdk-7-jre-lib – OpenJDK Java runtime (architecture independent
libraries)
二.挑选版本进行设置
root@linuxidc:~# apt-get install openjdk-7-jdk
三.装置景况变量
root@linuxidc:~# vi /etc/profile
在开辟的profile文件中增加如下内容

三.安装景况变量

3.安装情状变量

伍.验证配置是不是成功

java version “1.7.0_45”
OpenJDK Runtime Environment (rhel-2.4.3.3.el6-x86_64 u45-b15)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

set java environment

JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
让修改生效
root@linuxidc:~# source /etc/profile

[root@localhost java]# vi /etc/profile

[root@localhost java]# vi /etc/profile

i增加如下消息

i增加如下音讯

set java environment
JAVA_HOME=/usr/java/jdk1.8.0_131
JRE_HOME=/usr/java/jdk1.8.0_131/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

set java environment
JAVA_HOME=/usr/java/jdk1.8.0_131
JRE_HOME=/usr/java/jdk1.8.0_131/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH

:wq保存退出

:wq保存退出

让保存的意况变量生效

让保存的情况变量生效

[root@localhost java]# source /etc/profile

[root@localhost java]# source /etc/profile

验证jdk的布署是不是见效

验证jdk的布局是不是见效

[root@localhost java]# java -version
openjdk version “1.8.0_102”
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)

[root@localhost java]# java -version
openjdk version “1.8.0_102”
OpenJDK Runtime Environment (build 1.8.0_102-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)

 

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有