Configuration of J2EE development environment under Ubuntu -- sun-jdk1.7 Configuration

Source: Internet
Author: User

Note: It is best to perform the following operations under the root permission:

All the background colors are terminal commands.

JDK

  1. Download JDKStarting from which version of ubuntu apt-Get install is installed by default with openjdk. Although there is little difference, to prevent unexpected errors, download and install sun-JDK. Download the latest JDK http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.htm to Oracle official website.
  2. Decompress the fileGeneral direct download .tar.gz format files, manually or terminal commands extract tar-xzf jdk-7-linux-i586.tar.gz, get the folder jdk1.7.0.
  3. Move the JDK folderYou are free to choose. Generally, the development habits are put under the/usr/local/folder, and some people prefer to put it under/opt, you can also place the JDK address/usr/lib/JVM/in the system by default. This address also contains different versions of openjdk, if there is no JVM folder, create a mkdir/usr/lib/JVM. The root permission is required to move to these two addresses, MV jdk1.7.0/usr/lib/JVM. Generally in order to facilitate the configuration of environment variables, JDK file rename, the general online JDK file rename jdk-7-sun, MV/usr/lib/JVM/jdk1.7.0/usr/lib/JVM/Java-7-sun.
  4. Configure Environment VariablesIf Vim is installed, run Vim ~ /. Bashrc. If no, run gedit directly ~ /. Bashrc
    export JAVA_HOME=/usr/lib/jvm/java-7-sunexport JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATH

    Save the environment variable, exit the editor, and enter the command to make it take effect. Source ~ /. Bashrc. Enter the Env command to check whether the setting is successful.

  5. Configure the default JDKConfigure the JDK you installed as the default JDK. Enter the following command:
    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/java-7-sun/bin/java 300sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/java-7-sun/bin/javac 300sudo update-alternatives --config java

    If another JDK is installed in the system, you will be prompted to select the corresponding JDK 7.

  6. Test the JDK version.Enter the Java-version command to view the JDK version. If the result is similar to the following, the configuration is successful.
    java version "1.7.0" Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM)

    In the last step, an error may occur,

    Bash:/usr/lib/JVM/Java-7-sun/bin/Java: the file or directory does not exist.

    This is because the lack of 32-bit Runtime Library ia32-libs, 64-bit system installed 32-bit JDK, install this Runtime Library can solve

    sudo  apt-get install ia32-libs

    After the installation is complete, the original openjdk does not need to be deleted. You can change it later.

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.