知识屋:更实用的电脑技术知识网站
所在位置:首页 > 操作系统 > linux

ubuntu10.04安装sun jdk6

发布时间:2014-09-05 16:03:42作者:知识屋


ubuntu10.04安装sun jdk6
 
1. 下载JDK
 
地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html,下载jdk-6u33-linux-i586.bin
2. 安装
  www.zhishiwu.com  
官网的安装手册如下
 
[plain] 
Installation Instructions  
  
This procedure installs the Java Development Kit (JDK) for 32-bit Linux, using a self-extracting binary file. The JDK download includes the Java SE Runtime Environment (JRE) – you do not have to download the JRE separately.  
  
For RPM-based Linux distributions, like Red Hat or SuSE, refer to the RPM installation instructions.  
  
The name of the downloaded file has the following format:  
  
    jdk-6u<version>-linux-i586.bin  
            
  
<version>  
  
    jdk-6u18-linux-i586.bin  
  
To install, download this file and use the following instructions.  
  
<span style="font-weight: bold;">1. Download and check the download file size.</span>  
  
    You can download to any directory that you can write to.  
  
    This bundle can be installed by anyone (not only root users), in any location that the user can write to. However, only the root user can displace the system version of the Java platform supplied by Linux.  
  
<span style="font-weight: bold;">2. Make sure that execute permissions are set</span>  
    www.zhishiwu.com  
    Run this command:  
    % <span style="font-weight: bold; color: rgb(153, 153, 153);">chmod a+x jdk-6u <version>-linux-i586.bin </span>  
  
<span style="font-weight: bold;">3. Change directory to the location where you would like the files to be installed.</span>  
  
    The next step installs the JDK into the current directory.  
  
<span style="font-weight: bold;">4. Run the self-extracting binary.</span>  
  
    Execute the downloaded file, prepended by the path to it. For example, if the file is in the current directory, prepend it with " ./" (necessary if " ." is not in the PATH environment variable):  
  
    % <strong><span style="color:#999999;">./jdk-6u <version>-linux-i586.bin</span></strong><span style="color: rgb(102, 102, 102);">  
</span>  
    The binary code license is displayed, and you are prompted to agree to its terms.  
  
    The JDK files are installed in a directory called jdk1.6.0_<version> in the current directory. Follow this link to see its directory structure. The JDK documentation is a separate download.  
  
<strong>5. Delete the bin file if you want to save disk space.</strong>  
  
6. If you want to use Java within the browser, setup the plugin using the instructions in Manual Plugin Installation for Linux.  
  
    Note about Root Access: Installing the software automatically creates a directory called jdk1.6.0_ <version> . Note that if you choose to install the JDK into a system-wide location such as /usr/local, you must first become root to gain the necessary permissions. If you do not have root access, simply install the Java SE Runtime Environment into your home directory, or a subdirectory that you have permission to write to.  
    www.zhishiwu.com  
    Note about Overwriting Files: If you install the software in a directory that contains a subdirectory named jdk1.6.0_ <version> , the new software overwrites files of the same name in that jdk1.6.0_ <version> directory. Please be careful to rename the old directory if it contains files you would like to keep.  
  
    Note about System Preferences: By default, the installation script configures the system such that the backing store for system preferences is created inside the JDK's installation directory. If the JDK is installed on a network-mounted drive, it and the system preferences can be exported for sharing with Java runtime environments on other machines.   
执行命令   chmod a+x jdk-6u33-linux-i586.bin 修改bin文件权限,使其可执行。
然后执行   ./jdk-6u33-linux-i586.bin
将 会出现字幕,持续按回车键,直到屏幕出现需要输入yes/no,此时输入yes/y 回车,将会把JDK解压到当前文件夹,得到jdk1.6.0_33.
 
此时JDK安装完毕。下面进行配置。
3. 配置
3.1 配置环境变量
 
执行:sudo gedit /etc/environment
 
在 environment中修改如下信息:
 
[plain] 
PATH="........:/home/gg/jdk1.6.0_33/bin"  
CLASSPATH=".:/home/gg/jdk1.6.0_33/lib"  
JAVA_HOME="/home/gg/jdk1.6.0_33"  
其中/home/gg/是你的jdk安装目录
3.2 设置java和javac
 
由于ubuntu中有默认jdk还需要执行如下工作
执行代码:  www.zhishiwu.com  
 
[plain] 
sudo update-alternatives --install /usr/bin/java java /home/gg/jdk1.6.0_33/bin/java 300  
sudo update-alternatives --install /usr/bin/javac javac /home/gg/jdk1.6.0_33/bin/javac 300  
通过 这一步将我们安装的JDK加入java选单
3.3 配置默认的jdk
执行代码:sudo update-alternatives --config java
根据提示设置系统默认的JDK。
4. 测试
执行:java -version
此时显示的系统中的java就是刚刚安装的 java
 
 
作者 gangwazi0525
(免责声明:文章内容如涉及作品内容、版权和其它问题,请及时与我们联系,我们将在第一时间删除内容,文章内容仅供参考)
收藏
  • 人气文章
  • 最新文章
  • 下载排行榜
  • 热门排行榜