注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

艾伯特的鸟屋

 
 
 

日志

 
 

Ubuntu Linux: Install Latest Oracle Java 7 (手工)  

2013-10-11 23:00:18|  分类: linux |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
http://www.cyberciti.biz/faq/howto-installing-oracle-java7-on-ubuntu-linux/

Debian / Ubuntu and much other Linux distros are switching to OpenJDK (Open Java Development Kit). It is a free and open source implementation of the Java Platform, Standard Edition (Java SE). OpenJDK is the official Java SE 7 reference implementation and following packages are installed on Ubuntu Linux:
  1. openjdk-7-jdk - OpenJDK Development Kit (JDK)
  2. openjdk-7-jre - OpenJDK Java runtime, using Hotspot JIT
  3. icedtea-plugin - web browser plugin to execute Java applets (dependency package)

Find out installed JDK

To list all currently installed java implementation on the system, enter:
$ dpkg --list | grep jdk
Sample outputs:

Fig.01: Listing all installed jdk's on Ubuntu Linux

Fig.01: Listing all installed jdk's on Ubuntu Linux


You can also use the following command to list all installed packages providing information to set a bunch of java alternatives.
$ update-java-alternatives -l
Sample outputs:
java-1.6.0-openjdk-amd64 1061 /usr/lib/jvm/java-1.6.0-openjdk-amd64
java-1.7.0-openjdk-amd64 1051 /usr/lib/jvm/java-1.7.0-openjdk-amd64
(Fig.02: A list of all installed JDK's on the system

Finding out the default java version

Type the following command:
$ java -version
Sample outputs:

java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.5) (6b27-1.12.5-0ubuntu0.12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
(Fig.03: I am using OpenJDK 1.6 [openjdk and jre version 6])

Installing Oracle Java 7 On Ubuntu version 12.04 or 13.04+

The good news is you can install Oracle Java 7 easily and make it as the default source implementation of the Java platform. First, grab Oracle Java 7 directly from Oracle Java download page:

Fig.04: Download Oracle Java 7

Fig.04: Download Oracle Java 7


Make sure you download 32 bit (Linux x86 ~ jdk-7u21-linux-i586.tar.gz) or 64 bit (Linux x64 ~ jdk-7u21-linux-x64.tar.gz) JDK version in .tar.gz format:
Fig.05: Accept Oracle license and download either 64 or 32 bit version in tar.gz format

Fig.05: Accept Oracle license and download either 64 or 32 bit version in tar.gz format


Note: By default all files are downloaded in ~/Download/ ($HOME/Download/) directory.

Install jdk-7u21-linux-x64.tar.gz

Open a terminal and type the following command to list your files:
$ ls ~/Downloads/*.tar.gz
Sample outputs:

/home/nixcraft/Downloads/jdk-7u21-linux-x64.tar.gz

Untar the tar ball and install at /usr/lib/jvm/ directory:

 
sudo mkdir -p /usr/lib/jvm/
sudo tar xvf ~/Downloads/jdk-7u21-linux-x64.tar.gz -C /usr/lib/jvm
 

Sample outputs:

jdk1.7.0_21/
jdk1.7.0_21/include/
jdk1.7.0_21/include/jvmti.h
jdk1.7.0_21/include/jawt.h
jdk1.7.0_21/include/jvmticmlr.h
jdk1.7.0_21/include/jdwpTransport.h
jdk1.7.0_21/include/jni.h
jdk1.7.0_21/include/linux/
jdk1.7.0_21/include/linux/jawt_md.h
jdk1.7.0_21/include/linux/jni_md.h
jdk1.7.0_21/include/classfile_constants.h
jdk1.7.0_21/bin/
jdk1.7.0_21/bin/jhat
jdk1.7.0_21/bin/policytool
jdk1.7.0_21/bin/rmiregistry
jdk1.7.0_21/bin/jrunscript
jdk1.7.0_21/bin/javafxpackager
jdk1.7.0_21/bin/jcmd
...
..
...
jdk1.7.0_21/jre/plugin/
jdk1.7.0_21/jre/plugin/desktop/
jdk1.7.0_21/jre/plugin/desktop/sun_java.png
jdk1.7.0_21/jre/plugin/desktop/sun_java.desktop
jdk1.7.0_21/jre/COPYRIGHT
jdk1.7.0_21/jre/THIRDPARTYLICENSEREADME-JAVAFX.txt
jdk1.7.0_21/LICENSE
jdk1.7.0_21/COPYRIGHT
jdk1.7.0_21/THIRDPARTYLICENSEREADME-JAVAFX.txt

Oracle Java 7 has been installed in /usr/lib/jvm/jdk1.7.0_21/ directory. Type the following ln command to create a softlink:

cd /usr/lib/jvm
sudo ln -s jdk1.7.0_21 java-1.7.0-sun-amd64

Setting the default Java to use

Type the following command
$ sudo update-alternatives --config java
Sample outputs:

Fig.06: Setting the default Java to Oracle 7 Java

Fig.06: Setting the default Java to Oracle 7 Java

Update your ~/bashrc

Edit the file ~/bashrc, enter:

 
vi ~/bashrc
 

Set or update the JAVA_HOME and PATH shell variables as follows:

 
export JAVA_HOME="/usr/lib/jvm/jdk1.7.0_21"
export PATH="$PATH:$JAVA_HOME/bin"
 

Save and close the file.

Verify new java settings

Type the following command:

 
java -version
 

Sample outputs:

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

How do I configure Mozilla Firefox Java 7 plugin?

First, close running Firefox. Open a terminal and cd into /usr/lib/firefox-addons/plugins directory, enter:

 
cd /usr/lib/firefox-addons/plugins
 

Type the following command to create a softlink to libnpjp2.so, enter:

 
ln -s $JAVA_HOME/jre/lib/amd64/libnpjp2.so .
 

OR

 
ln -s /usr/lib/jvm/jdk1.7.0_21/jre/lib/amd64/libnpjp2.so .
 

How do I test whether Java is working on my Firefox?

Start the Firefox and visit this url to verify that Oracle 7 java Applet / plugin is working for Firefox:

Fig.07: Testing whether Java is working on my Firefox browser

Fig.07: Testing whether Java is working on my Firefox browser

So there you have it-the ultimate and official Oracle Java 7 JDK/JRE running on Ubuntu Linux and Firefox web-browser plugin.


  评论这张
 
阅读(165)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017