虚拟机ubuntu上安装JDK,及配置

一。安装部分

http://docs.oracle.com/javase/7/docs/webnotes/install/linux/linux-jdk.html

0.前奏:

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html下载的文件通过共享文件夹传入虚拟机,可在win7中查看后缀(控制面板-外观和个性化-文件夹选项-查看),在第三步注意后缀的吻合

很多文章分享为处理.bin文件,但目前官方下载仅有.tar.rpm两种,不适用!

Installation of the 64-bit JDK on Linux Platforms

This procedure installs the Java Development Kit (JDK) for 64-bit Linux, using an archive binary file (.tar.gz).

These instructions use the following file:

    jdk-7u<version>-linux-x64.tar.gz

1. Download the file. Before the file can be downloaded, you must accept the license agreement. The archive binary can be installed by anyone (not only root users), in any location that you can write to. However, only the root user can install the JDK into the system location.

2. Change directory to the location where you would like the JDK to be installed. Move the .tar.gz archive binary to the current directory.

3. Unpack the tarball and install the JDK.

    % tar zxvf jdk-7u<version>-linux-x64.tar.gz

The Java Development Kit files are installed in a directory called jdk1.7.0_<version> in the current directory.

4. Delete the .tar.gz file if you want to save disk space.


官方文档才是王道!

二。配置部分:

分析

ubuntu中的环境变量等参数保存在指定文件中,无法通过图形化界面修改,通过终端向配置文件中添加变量

各配置文件意义

      /etc/environment:设置整个系统的环境,与登录用户无关
     
 /etc/profile:系统的每个用户设置环境信息,当用户第一次登录时,该文件被执行并从/etc/profile.d目录的配置文件中搜集shell的设置
      
/etc/bash.bashrc:为每一个运行bash shell的用户执行此文件.当bash shell被打开时,该文件被读取.
      ~/.bashrc: 该文件包含专用于该登录用户bash shell的bash信息,当登录时以及每次打开新的shell时该该文件被读取

各配置的生效时间

/etc/environment:重启生效
/etc/profile:注销后登录生效
/etc/bash.bashrc:重新打开bash shell后生效
~/.bahsrc:重新打开bash shell后生效

文件修改权限

修改的文件为readonly,无法修改,!强制命令(如:w!)也无法执行。需先进入root权限,修改文件权限。

操作

1.修改权限

sudo su

输入密码

chmod 777 文件名

2.在  /etc/environment和 /etc/profile和 /etc/bash.bashrc中添加

1
vim /etc/profile
1
vim /etc/bash .bashrc 
vim /etc/environment

关于vim:
插入模式
輸入文本
編輯模式
執行命令,也稱為正常模式。
命令模式
執行  冒號 命令

插入模式並不是缺省的模式,您必須按下i來進入插入模式,在屏幕上輸入一些文字。按下<Esc>按鈕將從插入模式轉到編輯模式。該模式用於移動和操縱文本,有時以非常有趣的方式進行。 命令模式用於執行冒號命令,比如保存,查找/替換以及配置vim等。欲保存文本,您只需要在正常模式下輸入:進入命令模式並輸入:w filename<Enter>.退出vim請執行冒號命令:q.總結如下:

vim (启动vim)
i (进入插入模式)
<输入文本>
<Esc> (回到编辑模式)
:w filename (保存文件为'filename')
:q (退出vim)
vim filename (打开您刚才在vim中保存的文件)

請記住,最好的學習vim的方式是使用她.您可以通過內置的vim教程來學習vim的基本使用,只需要在終端中輸入vimtutor (有的系統中可能是vim-tutor).


在两个文件的末尾都加上下面一段

1
2
3
4
5
#set java environment
export JAVA_HOME=home/happy /java/jdk1 .7.0_55
export JRE_HOME= home/happy /java/jdk1 .7.0_55 /jre
export CLASSPATH=.:$JAVA_HOME /lib :$JRE_HOME /lib :$CLASSPATH
export PATH=$JAVA_HOME /bin :$JRE_HOME /bin :$PATH
3.重启(右上角happy按钮,重启),搞定
1
java –version

如下显示对应结果
安装JRE、JDK成功



参考链接:
1、在Ubuntu 10.10下安装JDK配置Eclipse及Tomcat【转载 + 订正】   http://www.cnblogs.com/evasnowind/archive/2011/01/05/1926059.html
2、ubuntu安装jdk全过程(仅供参考)  http://forum.ubuntu.org.cn/viewtopic.php?t=183803
3、java学习_jdk安装  http://www.cnblogs.com/shaoguobao/archive/2011/07/16/2108015.html





  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值