`
eimhee
  • 浏览: 2116131 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Ubuntu Linux: Install Latest Oracle Java 7

阅读更多

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:

http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

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
 
    • Now run
    • sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1
      sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1
      sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
       
    • This will assign Oracle JDK a priority of 1, which means that installing other JDKs will replace it as the default. Be sure to use a higher priority if you want Oracle JDK to remain the default.
    • Correct the file ownership and the permissions of the executables:
    • sudo chmod a+x /usr/bin/java 
      sudo chmod a+x /usr/bin/javac 
      sudo chmod a+x /usr/bin/javaws
      sudo chown -R root:root /usr/lib/jvm/jdk1.7.0
       N.B. remember - Java JDK has many more executables that you can similarly install as above. java,javac, javaws are probably the most frequently required.

      This answer lists the other executables available.

    • Run
sudo update-alternatives --config java

You will see output similar one below - choose the number of jdk1.7.0 - for example 3 in this list:

$sudo update-alternatives --config java
There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.

Check the version of you new JDK 7 installation:

java -version

java version “1.7.0”
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode) 

Repeat the above for:

sudo update-alternatives --config javac
sudo update-alternatives --config javaws
  • 大小: 10.7 KB
  • 大小: 6.7 KB
0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics