您的位置:首页 > 编程语言 > Java开发

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

2014-04-21 10:31 330 查看
一。安装部分

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、在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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: