`
wbj0110
  • 浏览: 1639052 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

Ubuntu 12.04 – install sun jdk 6-7

阅读更多

java logo

Ubuntu GNU/Linux 12.04 LTS (Precise Pangolin) released. I wanted to manually install the Sun JDK 6 and 7 on Ubuntu.

Updated for Ubuntu GNU/Linux 13.04 (Raring Ringtail).

Updated for Ubuntu GNU/Linux 12.10 (Quantal Quetzal).

Installing Sun JDK 6 on Ubuntu 12.04 / 12.10 / 13.04:

  • Make the bin file executeable:
chmod +x jdk-6u32-linux-x64.bin
  • Extract the bin file:
./jdk-6u32-linux-x64.bin
  • For Ubuntu 13.04: There is no longer a jvm folder in /usr/lib, therefore create jvm folder
sudo mkdir /usr/lib/jvm
  • Move extracted folder to this location:
sudo mv jdk1.6.0_38 /usr/lib/jvm/jdk1.6.0_38
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_38/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_38/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_38/bin/javaws 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
  • java version test:
java -version
  • Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
  • Enable Java plugin for Mozilla Firefox (even for Chrome)
#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_38/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_38/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

Installing Sun JDK 7 on Ubuntu 12.04 / 12.10 / 13.04:

  • Download the sun jdk 7 tar file from here
  • Extract the tar file:
tar -xvzf jdk-7u11-linux-x64.tar.gz
  • For Ubuntu 13.04: There is no longer a jvm folder in /usr/lib, therefore create jvm folder
sudo mkdir /usr/lib/jvm
  • Move extracted folder to this location:
sudo mv jdk1.7.0_11 /usr/lib/jvm/jdk1.7.0_11
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_11/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_11/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_11/bin/javaws 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
  • java version test:
java -version
  • Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
  • Enable Java plugin for Mozilla Firefox (even for Chrome)
#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_11/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_11/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

Update: I have added Java Web Start configuration (Thanks Jack).

Update: I have added Java Plugin configuration for Mozilla Firefox even for Chrome (Thanks shetty).

Update: JAVA_HOME configuration: Some tools require JAVA_HOME variable. You can set JAVA_HOME in Ubuntu so simple: Edit the file .bashrc under your home directory and add the following lines: (if .bashrc is hidden, click in Nautilus Menu View > Show Hidden Files)

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_11 or /usr/lib/jvm/jdk1.6.0_38
export PATH=$JAVA_HOME/bin:$PATH

or add this JAVA_HOME=/usr/lib/jvm/jdk1.7.0_11 in /etc/environment with sudo gedit /etc/environment
分享到:
评论

相关推荐

    MTk android 编译环境大家

    `$ sudo apt-get install sun-java6-jdk` 对于 Froyo 和更老的 Android 版本,需要使用 Java 5: `$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"` `$ sudo add-apt-...

    A20 Android编译服务器搭建

    2. 使用`chmod`命令使其可执行,然后运行安装脚本`./jdk-6u45-linux-x64.bin`。 3. 将JDK移动到`/opt`目录,并使用`update-alternatives`设置路径和优先级。 4. 通过`update-alternatives`命令选择默认的JDK版本。 5...

    download android source code

    $ sudo apt-get install sun-java6-jdk ``` 在安装了所有必备软件后,继续安装其他必要的包: 1. 对于Ubuntu 12.04,运行以下命令: ``` $ sudo apt-get install git gnupg flex bison gperf build-essential ...

    高通编译环境搭建

    使用 `chmod a+x jdk-6u45-linux-x64.bin` 命令赋予执行权限。 4. **运行程序进行解压** 执行 `./jdk-6u45-linux-x64.bin` 进行解压安装。 5. **创建目录并复制** 创建 JDK 的安装目录 `/usr/lib/jvm/` 并将...

    64位Ubuntu,Eclipse新建Android project后缺失R文件的原因分析.docx

    首先,问题出现在64位Ubuntu 12.04系统上,开发者已经配置了正确的sun-JDK 1.7,并且安装了最新的ADT-Eclipse-SDK集成包。尽管JDK配置无误,SDK也已更新至最新版本,但首次尝试创建Android Application Project时,...

    全志A31开发环境搭建

    - `sudo apt-get install sun-java6-jdk` (适用于Ubuntu 64位) - `sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib...

    Rhadoop 资料

    首先,用户需要准备Linux环境,作者张丹在文档中推荐使用Ubuntu 12.04 64位版本。接着,用户需要安装JDK(Java Development Kit),因为RHadoop的运行依赖于Java环境。文档中特别指出需要从Oracle SUN官方下载1.6.x...

Global site tag (gtag.js) - Google Analytics