ubuntu10.04安裝sun jdk6

1. 下載JDK

地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html,下載jdk-6u33-linux-i586.bin
2. 安裝

官網的安裝手冊如下

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.

1. Download and check the download file size.

    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.

2. Make sure that execute permissions are set

    Run this command:
    % chmod a+x jdk-6u <version>-linux-i586.bin 

3. Change directory to the location where you would like the files to be installed.

    The next step installs the JDK into the current directory.

4. Run the self-extracting binary.

    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):

    % ./jdk-6u <version>-linux-i586.bin

    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.

5. Delete the bin file if you want to save disk space.

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.

    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中修改如下信息:

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還需要執行如下工作
執行代碼:

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章