CentOS下安装JDK的三种方法

来源:Linux社区  作者:spiders

http://www.linuxidc.com/Linux/2016-09/134941.htm

由于各Linux开发厂商的不同,因此不同开发厂商的Linux版本操作细节也不一样,今天就来说一下CentOS下JDK的安装:

方法一:手动解压JDK的压缩包,然后设置环境变量

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

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

2.下载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

3.设置环境变量

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

在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

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

1.查看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
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.7.0-openjdk-1.7.0.75.x86_64

3.设置环境变量

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

在profile文件中添加如下内容

#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

4.验证(同上一方法)

方法三:用rpm安装JDK

1.下载rpm安装文件

[root@localhost ~]$ curl -O http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.rpm

2.使用rpm命令安装

[root@localhost  ~]# rpm -ivh jdk-7u79-linux-x64.rpm

3.设置环境变量

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

在打开的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

4.验证(同上一方法)

注:和yum安装类似,不用设置环境变量就可以运行java命令。rpm安装方式默认会把jdk安装到/usr/java/jdk1.7.0_79,然后通过三层链接,链接到/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)
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)

2.选择版本进行安装

root@linuxidc:~# apt-get install openjdk-7-jdk

3.设置环境变量

root@linuxidc:~# vi /etc/profile

在打开的profile文件中添加如下内容

#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

4.验证(同上一方法)

Ubuntu 14.04安装JDK1.8.0_25与配置环境变量 http://www.linuxidc.com/Linux/2015-01/112030.htm 

CentOS 搭建JDK环境  http://www.linuxidc.com/Linux/2015-06/118879.htm 

Ubuntu 14.04安装JDK1.8.0_25与配置环境变量  http://www.linuxidc.com/Linux/2015-01/112030.htm 

Ubuntu 14.04 LTS安装Oracle JDK 1.8  http://www.linuxidc.com/Linux/2014-11/109216.htm 

CentOS6.3安装JDK和环境配置 http://www.linuxidc.com/Linux/2012-09/70780.htm 

Ubuntu 14.04 安装 JDK8  http://www.linuxidc.com/Linux/2014-09/106218.htm 

Ubuntu下安装JDK图文解析 http://www.linuxidc.com/Linux/2014-09/107291.htm 

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-09/134941.htm

 

转载于:https://www.cnblogs.com/yuluoxingkong/p/7879051.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/390767.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

MapReduce编程

自定义Mapper类 class TokenizerMapper extends Mapper<Object, Text, Text, IntWritable> &#xff5b; … }自定义mapper类都必须实现Mapper类&#xff0c;有4个类型参数&#xff0c;分别是&#xff1a; Object&#xff1a;Input Key Type-------------K1Text: Input…

统计信息在数据库中的作用_统计在行业中的作用

统计信息在数据库中的作用数据科学与机器学习 (DATA SCIENCE AND MACHINE LEARNING) Statistics are everywhere, and most industries rely on statistics and statistical thinking to support their business. The interest to grasp on statistics also required to become…

IOS手机关于音乐自动播放问题的解决办法

2019独角兽企业重金招聘Python工程师标准>>> 评估手机自带浏览器不能识别 aduio标签重的autoplay属性 也不能自动执行play()方法 一个有效的解决方案是在微信jssdk中调用play方法 document.addEventListener("WeixinJSBridgeReady", function () { docum…

svg标签和svg文件区别_什么是SVG文件? SVG图片和标签说明

svg标签和svg文件区别SVG (SVG) SVG or Scalable Vector Graphics is a web standard for defining vector-based graphics in web pages. Based on XML the SVG standard provides markup to describe paths, shapes, and text within a viewport. The markup can be embedded…

开发人员怎么看实施人员

英文原文&#xff1a;What Developers Think Of Operations&#xff0c;翻译&#xff1a;张红月CSDN 在一个公司里面&#xff0c;开发和产品实施对于IS/IT的使用是至关重要的&#xff0c;一个负责产品的研发工作&#xff0c;另外一个负责产品的安装、调试等工作。但是在开发人员…

怎么评价两组数据是否接近_接近组数据(组间)

怎么评价两组数据是否接近接近组数据(组间) (Approaching group data (between-group)) A typical situation regarding solving an experimental question using a data-driven approach involves several groups that differ in (hopefully) one, sometimes more variables.使…

代码审计之DocCms漏洞分析

0x01 前言 DocCms[音译&#xff1a;稻壳Cms] &#xff0c;定位于为企业、站长、开发者、网络公司、VI策划设计公司、SEO推广营销公司、网站初学者等用户 量身打造的一款全新企业建站、内容管理系统&#xff0c;服务于企业品牌信息化建设&#xff0c;也适应用个人、门户网站建设…

你让,勋爵? 使用Jenkins声明性管道的Docker中的Docker

Resources. When they are unlimited they are not important. But when theyre limited, boy do you have challenges! 资源。 当它们不受限制时&#xff0c;它们并不重要。 但是&#xff0c;当他们受到限制时&#xff0c;男孩你有挑战&#xff01; Recently, my team has fa…

翻译(九)——Clustered Indexes: Stairway to SQL Server Indexes Level 3

原文链接&#xff1a;www.sqlservercentral.com/articles/StairwaySeries/72351/ Clustered Indexes: Stairway to SQL Server Indexes Level 3 By David Durant, 2013/01/25 (first published: 2011/06/22) The Series 本文是阶梯系列的一部分&#xff1a;SQL Server索引的阶梯…

power bi 中计算_Power BI中的期间比较

power bi 中计算Just recently, I’ve come across a question on the LinkedIn platform, if it’s possible to create the following visualization in Power BI:就在最近&#xff0c;我是否在LinkedIn平台上遇到了一个问题&#xff0c;是否有可能在Power BI中创建以下可视化…

-Hive-

Hive定义 Hive 是一种数据仓库技术&#xff0c;用于查询和管理存储在分布式环境下的大数据集。构建于Hadoop的HDFS和MapReduce上&#xff0c;用于管理和查询分析结构化/非结构化数据的数据仓库; 使用HQL&#xff08;类SQL语句&#xff09;作为查询接口&#xff1b;使用HDFS作…

CentOS 7 安装 JDK

2019独角兽企业重金招聘Python工程师标准>>> 1、下载oracle jdk 下载地址&#xff1a; http://www.oracle.com/technetwork/java/javase/downloads/index.html 选择同一协议&#xff0c;下载rpm格式版本jdk&#xff0c;或tar.gz格式jdk。 2、卸载本机openjdk 2.1、查…

javascript 布尔_JavaScript布尔说明-如何在JavaScript中使用布尔

javascript 布尔布尔型 (Boolean) Booleans are a primitive datatype commonly used in computer programming languages. By definition, a boolean has two possible values: true or false.布尔值是计算机编程语言中常用的原始数据类型。 根据定义&#xff0c;布尔值有两个…

如何进行数据分析统计_对您不了解的数据集进行统计分析

如何进行数据分析统计Recently, I took the opportunity to work on a competition held by Wells Fargo (Mindsumo). The dataset provided was just a bunch of numbers in various columns with no indication of what the data might be. I always thought that the analys…

经典:区间dp-合并石子

题目链接 &#xff1a;http://acm.nyist.edu.cn/JudgeOnline/problem.php?pid737 这个动态规划的思是&#xff0c;要得出合并n堆石子的最优答案可以从小到大枚举所有石子合并的最优情况&#xff0c;例如要合并5堆石子就可以从&#xff0c;最优的23和14中得到最佳的答案。从两堆…

常见排序算法_解释的算法-它们是什么以及常见的排序算法

常见排序算法In its most basic form, an algorithm is a set of detailed step-by-step instructions to complete a task. For example, an algorithm to make coffee in a french press would be:在最基本的形式中&#xff0c;算法是一组完成任务的详细分步说明。 例如&…

020-Spring Boot 监控和度量

一、概述 通过配置使用actuator查看监控和度量信息 二、使用 2.1、建立web项目&#xff0c;增加pom <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency> 启动项目&a…

matplotlib布局_Matplotlib多列,行跨度布局

matplotlib布局For Visualization in Python, Matplotlib library has been the workhorse for quite some time now. It has held its own even after more nimble rivals with easier code interface and capabilities like seaborn, plotly, bokeh etc. have arrived on the…

Hadoop生态系统

大数据架构-Lambda Lambda架构由Storm的作者Nathan Marz提出。旨在设计出一个能满足实时大数据系统关键特性的架构&#xff0c;具有高容错、低延时和可扩展等特性。Lambda架构整合离线计算和实时计算&#xff0c;融合不可变性&#xff08;Immutability&#xff09;&#xff0c…

javascript之 原生document.querySelector和querySelectorAll方法

querySelector和querySelectorAll是W3C提供的 新的查询接口&#xff0c;其主要特点如下&#xff1a; 1、querySelector只返回匹配的第一个元素&#xff0c;如果没有匹配项&#xff0c;返回null。 2、querySelectorAll返回匹配的元素集合&#xff0c;如果没有匹配项&#xff0c;…