linux环境下的jdk安装与环境变量配置

来源:互联网 发布:北方数据 股票 编辑:程序博客网 时间:2024/04/30 11:21

第一步,下载JDK


方法之一:从官网下载

http://www.oracle.com/technetwork/java/javase/downloads/index.html

本文选择的是jdk6的31版:

Java SE 6 Update 31

This release includes security fixes. Learn morearrow

 

JDK

Download JDK

 

JDK 6 Docs

  • Installation Instructions
  • ReadMe
  • ReleaseNotes
  • Oracle License
  • Java SE Products
  • Third Party Licenses
  • Certified System Configurations

JRE

Download JRE

点击jdk下面的Download图标,进入下载页面:


 Java SE Development Kit 6 Update 31

You must accept the Oracle Binary Code License Agreement for Java SE to download this software.

 Accept License Agreement      Decline License Agreement

 

 Product / File Description

File Size

Download

选择左边的Accept License Agreement

下载文件如下: Linux x6481.62 MB   jdk-6u31-linux-x64.bin


下载完成后,就可以准备开始安装了。

当然,也可以选择从其他网站或个人下载拷贝。



第二步,安装JDK


1, 用root账户将下载的bin文件拷贝到/usr/lib/jvm下;

也可以用命令行在普通账户下拷贝:

sudo cp  文件名 /usr/lib/jvm

(若尚未生成jvm目录,可以使用命令 sudo mkdir -p /usr/lib/jvm)

2, 安装jdk

sudo chmod a+x 文件名

sudo ./文件名

当提示press ENTER for continue ...时,请按回车键。





第三步:配置环境变量


1,更改配置文件

sudo vim /etc/profile

按下i键进入插入模式

在文件最后加入如下两行配置:

export JAVA_HOME=/usr/lib/jvm/安装的文件夹

export PATH=$JAVA_HOME/bin:$PATH

按下Esc键,退出插入模式。

键入:wq或者:x保存退出。

2,激活配置文件

方法一:重启电脑

方法二:source /etc/profile



第四步:OK了!

输入java -version,看看现在的版本是不是jdk1.6.0_31呢!



附录:当有多个java版本时,怎样配置选定的版本。

(未完)


原创粉丝点击