Build a java Development Environment in Ubuntu 14.04 -- 1--JDK installation, 14.04 -- 1 -- jdk

Source: Internet
Author: User

Build a java Development Environment in Ubuntu 14.04 -- 1--JDK installation, 14.04 -- 1 -- jdk

Note: The following content is my personal experience. I have been in touch with the ubuntu system since 10.04 and have been in the twinkling of an eye for four years. I have visited various related forums and found that from the beginning to the present, many people on the Forum asked questions about JAVA environment configuration. So I will summarize my personal experience as follows, which is only for reference by new users!

Start.

 

First, the java development environment includes some basic content:

1. jdk installation ---- jdk-6u45-linux-x64.bin

2. Install ----eclipse-jee-kepler-SR2-linux-gtk-x86_64.tar.gz in eclipse

3. tomcat installation ----apache-tomcat-6.0.39.tar.gz

4. Database Installation

Start with JDK installation.

In fact, to sum up the installation of JDK, extract andConfigure Environment Variables

First decompress the jdk-6u45-linux-x64.bin in a proper place, the operation is as follows:

Cd/opt # Go To The/opt directory sudo mkdir DevelopTools # create the DevelopTools directory cd DevelopToolssudo mkdir jvmcd jvmsudo cp/home/download/jdk-6u45-linux-x64.bin/opt/DevelopTools/jvmsudo chmod a + x jdk-6u45-linux-x64.binsudo sh jdk-6u45-linux-x64.bin # unzip to get the folder tone @ ubuntu: /opt/DevelopTools/jvm $ ls-l total usage 4drwxr-xr-x 8 root 4096 2013 jdk1.6.0 _ 45

The JDK has been decompressed by a few steps above. In fact, the writing steps are very simple and there is nothing to say.

 

The following section describes how to configure environment variables. This step is depressing for many new users. problems often occur here, and even the system cannot log on normally (this is because the system enters the password and returns to the logon page cyclically)

To configure environment variables,

The first is the symbol. It is clear that in ubuntu or other linux distributions, When configuring environment variables, the separator is [:] instead of [;].

The second is to back up files before configuration. This is actually a good habit. If an error occurs, you can restore it immediately.

Let's get started and start to configure environment variables. First, you have to think about it. Do you want to apply JDK to all accounts that the system can use or is it just the current user? In fact, there is nothing here, that is, configuring the environment variable

Files are different.

First, let's configure the JDK that can be used by all users as an example to configure environment variables.

Back up the file to be modified

sudo cp /etc/profile /etc/profile.old

Edit File

sudo gedit /etc/profile

Add the following content at the end of the file:

#JDK PATHexport JAVA_HOME=/opt/DevelopTools/jvm/jdk1.6.0_45export JRE_HOME=/opt/DevelopTools/jvm/jdk1.6.0_45/jreexport CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

The following is a description of the content added above

# JDK PATHexport JAVA_HOME =/opt/DevelopTools/jvm/jdk1.6.0 _ 45 # Tell the system that JAVA_HOME is at/opt/DevelopTools/jvm/jdk1.6.0 _ 45 (this is the path decompressed above) export JRE_HOME =/opt/DevelopTools/jvm/jdk1.6.0 _ 45/jre # Tell the system that JRE_HOME is in opt/DevelopTools/jvm/jdk1.6.0 _ 45/jreexport CLASSPATH =.: $ JAVA_HOME/lib: $ JRE_HOME/lib: $ CLASSPATH
# Configuring CLASSPATH. If you have experience configuring CLASSPATH in windows, it must be easy to understand.
# [.] Add the current directory to CLASSPATH
# [$ JAVA_HOME/lib] Add the lib directory under JAVA_HOME to CLASSPATH
# [$ JRE_HOME/lib] Add the lib directory under JRE_HOME to CLASSPATH
# [$ CLASSPATH] append the original CLASSPATH
# The symbol description above [:] is equivalent to [;] in windows. [$ JAVA_HOME/lib] is written in winodws as % JAVA_HOME % \ libexport PATH = $ JAVA_HOME/bin: $ JRE_HOME/bin: $ PATH.
# Configure PATH [$ JAVA_HOME/bin] and [$ JRE_HOME/bin:] to add the bin in JAVA_HOME and JRE_HOME to the PATH
# $ PATH append the original PATH
 

 

After saving/etc/profile, the environment variable is configured. Note the configuration in PATH,

The most common error is

Set

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

Written

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin

 

This will cause you to progress the system after restarting. Why. Because you write it like this, it is equivalent to re-assigning a value to PATH instead of appending JDK-related content. Therefore, unexpected errors may occur.

 

Many new users do not dare to modify the file, or do not know whether the modification is correct. The configuration is correct or not by checking javac-version after restart.

In fact, to avoid errors, You can first verify whether the modified profile file is correct.

Open Terminal

Input

 source /etc/profile

 

If there is no prompt, continue to enter java-version. If the output similar to the following is displayed, it will prove that you have succeeded. Restart with confidence.

 

tone@ubuntu:~$ java -versionjava version "1.6.0_45"Java(TM) SE Runtime Environment (build 1.6.0_45-b06)Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)tone@ubuntu:~$ javac -versionjavac 1.6.0_45

 

By the way, I forgot to mention that the configuration is only applicable to the JDK environment variables that take effect for the current user. The/etc/profile is global. to configure the current user, modify the $ HOME/. profile file.

 

Well, I wrote this article today. There may be typos in the text, all of which are damn input methods! Please forgive me. For other configurations, please pay attention to future articles.

 

      

Related Article

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.