Configuring Java environments and issues under Linux

Source: Internet
Author: User

One: Download jdk

Download stable version http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk7-downloads-1880260.html

Command: wget http://download.oracle.com/otn-pub/java/jdk/7u79-b15/jdk-7u79-linux-x64.tar.gz

Two: Configuration (source configuration mode)

Configuration steps

1: Create a directory:

sudo mkdir/usr/local/java then enter the password

2: Move the jdk-7u79-linux-x64.gz under the new directory (/usr/local/java/) and unzip the jdk-7u79-linux-x64.gz

Decompression Source package: TAR-ZXVF jdk-7u79-linux-x64.gz

3: Configure system Environment variables

The first way:
#export java_home=/usr/local/java/jdk1.7.0_79
#export path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin: $PATH
#export classpath=.: $JAVA _home/lib: $JAVA _home/jre/lib

The second way:

java_home=/usr/local/java/jdk1.7.0_79
Path= $PATH: $JAVA _home/bin: $JAVA _home/jre/bin
Classpath=.: $JAVA _home/lib: $JAVA _home/jre/lib
Export Java_home PATH CLASSPATH

The role of the export here I searched for its role: summarized as follows

If you do not add export, and then directly "Source/etc/profile", this configuration is not written to the system files;

When you add export, when you execute "source/etc/profile", this configuration will be written to the configuration file;

I do not know whether the understanding is correct;

Just asked a Daniel, gave me one, said the following:

If this configuration needs to be performed in other subroutines, export is required to make the variable an environment variable export PATH

If the variable is the content of the amplified variable, the contents of "$ variable name" or ${variable} can be used; path= "$PATH":/home/bin; or Path=${path}:/home/bin

In general, the Java environment is now configured, but if your system is already configured with a Java environment, then there may be a problem;

(c): Question

On my server, the system itself is already installed Java; Use commands to view JDK information

Rpm-qa | grep java

I have the following:

Then the environment was already configured in the previous step, but when you use java-version to view the JDK is not what you want, such as

You can see that if you use javac-version you can see that the display is actually my own version, but java-version shows the version of the openjdk that comes with the system. I google search, Baidu, and finally

To see the/usr/bin below, use the "ls-l" command to get the following command, where you can see the Java properties

You can see that the Java point here is not the Java directory I configured, so I need to tell the directory that it points to my configuration, and configure the following

Under the Usr/bin directory:

MV Java java.bakln-s/usr/local/java/jdk1.7.0_79/bin/java/usr/bin/java

After you configure it, see

You can see the Java version of your own configuration with java-version.

Four: summary

Recently will be recorded in the process of configuring these and the configuration process encountered problems, the next will be configured under Nginx, did not try, still do not know the success of their own toss, and the time is more urgent, perhaps the eldest brother himself, or I first try. There is also an article that will be recorded in MySQL installation. I have been doing this for a long time. Efforts, refueling, now is the expansion of knowledge stage ...

Configuring Java environments and issues under Linux

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.