Install JDK 7 in Ubuntu 12.04

Source: Internet
Author: User


Install JDK 7 in Ubuntu 12.04
Today, I want to download the source code of an Android system. I heard that it is quite easy to download the source code in a linux system. I want to configure an environment in my new Linux virtual machine, the result is a half-day shell allocated by a JDK. Finally, I saw the following information: 1 @-VirtualBox :~ $ Java-version2java version "1.7.0 _ 07" 3 Java (TM) SE Runtime Environment (build 1.7.0 _ 07-b10) 4 Java HotSpot (TM) Client VM (build 23.3-b01, mixed mode) to avoid detours in the future, it is also a learning note. I will write down the configuration process. Download JDK 7 www.2cto.com to the official Oracle website to download the latest JDK 7. Currently the latest is: jdk-7u7-linux-i586.tar.gz unzip installation I install jdk to/opt/java, so in the Terminal window to execute the following code: 1 sudo mkdir/opt/java2sudo tar zxvf/home/david/Downloads/jdk-7u7-linux-i586.tar.gz-C/opt/java modify environment variables if you are using the root account login can be modified as follows: 1. open/etc/environment1gedit/etc/environment2. modify the file www.2cto.com 1 PATH = "/usr/local/sbin:/usr/local/bin:/usr/sbin: /usr/bin:/sbin:/bin:/usr/games: $ {JAVA_HOME}/bin "2JAVA_HOME =/opt/ja Va/jdk1.7.0 _ 073JRE_HOME =$ {JAVA_HOME}/jre4CLASSPATH =.: $ {JAVA_HOME}/lib: $ {JRE_HOME}/lib "3. reload bashrc1 <span style = "font-size: 12px;"> source ~ /. Bashrc </span> if you are not using the root account or you are not authorized to modify the above file, you can use the following method: 1. Execute the following command www.2cto.com 1vim ~ /. BashrcNOTE: if the execution is complete: vim ~ /. Bashrc outputs the following information: 1 program "vim" is included in the following package: 2 * vim3 * vim-gnome4 * vim-tiny5 * vim-gtk6 * vim-nox7 please try: sudo apt-get install <selected software package> indicates that you have not installed vim. Run: 1 sudo apt-get install vim. Press Y to press Enter, wait until the installation is complete. open the bashrc file and add the following entry to it: www.2cto.com 1 export JAVA_HOME =/opt/java/jdk1.7.0 _ 072 export JRE_HOME =$ {JAVA_HOME}/jre 3 export CLASSPATH =.: $ {JAVA_HOME}/lib :$ {JRE_HOME}/lib 4 export PATH =$ {JAVA_HOME}/bin: $ PATH NOTE, you must press the letter I to enter the editing mode before moving the cursor input.
After entering the preceding content, Press esc to exit the editing mode, move the cursor to the end, and enter ': wq! 'To save and exit. 3. Save and execute the following command to make it take effect immediately. 1 source ~ /. Bashrc4. configure the default JDK version. Because ubuntu may have the default JDK, such as openjdk, the following configuration is required to set the JDK we have installed as the default JDK version: www.2cto.com 1 sudo update-alternatives -- install/usr/bin/java/opt/java/jdk1.7.0 _ 07/bin/java 3002 sudo update-alternatives -- install/usr/bin/javac javac/opt/java/jdk1.7.0 _ 07/bin/javac 3003 sudo update-alternatives -- install/usr/bin/jar/opt/java/jdk1.7.0 _ 07/bin/jar 3004 sudo update-alternatives -- install /Usr/bin/javah/opt/java/jdk1.7.0 _ 07/bin/javah 3005 sudo update-alternatives -- install/usr/bin/javap/opt/java/jdk1.7.0 _ 07/bin/javap 300 and then execute: www.2cto.com 1 sudo update-alternatives -- config the java system will list various JDK versions, as shown below: There are three candidates to replace java (provide/usr/bin/java ). 1 select path priority State 2 bytes 3*0/usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 automatic mode 4 1/usr/lib/jvm/java-6-openjdk/jre/ bin/java 1061 manual mode 5 2/usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode 6 3/opt/java/jdk1.7.0 _ 07/ bin/java 300 manual mode to maintain the current value [*] Press enter, alternatively, enter the selected number: 3 update-alternatives:/opt/java/jdk1.7.0 _ 07/bin/java to provide/usr/bin/java (java ), in manual mode. NOTE: if there is not the above prompt, but there is only one candidate item in the Link Group java:/opt/java/jdk1.7.0 _ 07/bin/java without configuration. This is also normal, so ignore it. Www.2cto.com check JDK1java-version1 @-VirtualBox :~ $ Java-version2java version "1.7.0 _ 07" 3 Java (TM) SE Runtime Environment (build 1.7.0 _ 07-b10) 4 Java HotSpot (TM) Client VM (build 23.3-b01, mixed mode)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.