CentOS 6.6 under JDK1.7 Installation and configuration (Linux) Classic Introduction detailed case

Source: Internet
Author: User
Tags bz2

Recently used more Linux, in the Web site to find some of the JDK installation of Linux tutorial, the process is some but a lot of details are not shown, so I spent a bit of time to summarize, I hope that everyone can help ...

CentOS under JDK1.7 Installation and configuration ( Linux )

First, before installing Sun's JDK, check to see if the JDK is installed on the system. In general, the CentOS system installs OPENJDK by default, but the OPENJDK part is incompatible with the sun JDK and intends to reinstall Sun JDK1.7 for development.

1. We can view openjdk specific version information via RPM command

#rpm-qa |grep Java

2. We can also view the OPENJDK version information via the RPM command

# RPM-QA |grep JDK

3. Of course, we can also view the OPENJDK version information used by the current system

#java –version

By the above we can know that the system is installed by default OpenJDK 1.7.0_65

Second, through the above inspection, we found that the system has installed the OpenJDK 1.7.0_65, but openjdk part of the content is incompatible with the sun JDK, so intends to reinstall Sun JDK1.7 to develop. So we need to remove the installed OPENJDK.

1. Delete the installed OPENJDK, you can use the following command:

#rpm –e JDK related (normal delete command, delete a specific package, if you encounter dependencies, you cannot delete)

#rpm-e–-nodeps JDK Related (Force Delete command, ignore dependency, delete specific package. If you use the above command to delete, prompt for other dependent files, then use this command can be strongly deleted)

TIPS: Here's JDK correlation refers to the use of a query command in the previous step find out. JDK the relevant documents.

(I still recommend that you use the Force Delete command).

2. Uninstalling OpenJDK

When you use the following command to uninstall OPENJDK if the following error (may appear), the specific reason immediately know.

#rpm –e–nodeps java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el6_5.i686

What is the reason for this? Look carefully we use the ordinary user login, permissions are not enough, so we want to switch the normal to the root user for further operation, the Switch command is:

#su –root/sudo passwd Root

Because SU does not have the restriction of permissions after switching to Superuser root, Su is not able to hold multiple systems administered by a. If you use SU to switch to the Superuser to manage the system, it is not clear what work is done by which administrator. In particular, for the management of the server with many people involved in the management, it is best for each administrator's technical expertise and scope of management, and a targeted delegation of authority, and agreed on what tools they use to complete their work, then we need to use sudo.

B. Through sudo, we can put some super-privileged targeted decentralization, and does not require the ordinary user to know the root password, so sudo is more secure than the unrestricted-access Su, so sudo can also be referred to as a restricted Su, and sudo is required to be licensed, So also known as the licensing of SU;

C.sudo the process of executing the command is that the current user switches to root (or the other user specified to switch to), then executes the command as root (or another specified switch to the user), and then returns directly to the current user after the execution is completed, which is premised on the configuration file of sudo/etc/ Sudoers to authorize;

User state before switching using the SU command:

User state after switching using the SU command:

#su –root

Note: Switching to the root user will allow you to enter the password, which is no longer detailed here ...

All right, we've switched, so we're just trying to do this with the same order:

#rpm –e–nodeps java-1.7.0-openjdk-1.7.0.65-2.5.1.2.el6_5.i686

After the execution of this sentence, we then use #rpm-qa |grep java to see if the uninstall is finished

#rpm-qa |grep Java

Did you see that? is not the OpenJDK1.7 of which was unloaded out?

Then we'll immediately unload the remaining two in the same way:

#rpm –e–nodeps java-1.6.0-openjdk-1.6.0.0-11.1.13.4.el6_5.i686

#rpm –e–nodeps Tzdata-java-2014g-1.el6.noarch

OK, so far, we need to unload all the stuff, so let's verify if all the uninstallation is complete?

#rpm-qa |grep Java

Did you see that? Is it all gone?

3. Next to ensure that the JDK has been completely removed, you need to execute the query command #find/-name JDK Related:

#find/-name JDK

#find/-name JRE

#find/-name GCJ

If the query out also participates in the catalogue, can use # rm-rf directory, delete the remaining directories one by one.

The removal of the JDK has been completed.

Third, download and install the JDK

1. Download the JDK

recommended to http://www.oracle.com official website Download, I here is the operating system so find the specified download interface

Since I'm installing JDK7, I'm going to the JDK7 download interface and download the JDK according to my needs, which I'm not going to describe here. We can see that the Linux x86 system has two forms of JDK, which one should we use? This depends on your personal situation, I first say the two kinds of JDK (jdk-7u79-linux-i586.rpm/jdk-7u79-linux-i586.tar.gz) what is different!

In simple terms:

The RPM format is an installation package that can be installed directly.
. tar.gz just packages the files and cannot be installed, which is equivalent to putting multiple files together for packaging.

In more detail:

1, *.rpm form of binary package
Installation: Rpm-ivh *.rpm
Uninstall: Rpm-e Packgename
Description: RPM (RedHat packge Manager) is a software package manager for RedHat, which makes it easy to install, upgrade, uninstall, verify, query, and so on in RPM-form packages, with simple installation It is also possible to remove the files that are installed in multiple directories when uninstalling, so it is recommended that beginners use the RPM-style software package whenever possible. RPM parameters in the-I is installed,-V is the checksum,-H is a hash to display the installation progress, *.RPM is the package file name (here *.rpm refers to *). src.rpm other than RPM); The parameter-E is the removal of the package, Packgename is the package name, which differs from the file name of the package, which is often the string that precedes the version number in the file name, such as apache-3.1.12-i386.rpm and apache-devel-3 .1.12-i386.rpm is the package file name, and their package names are Apache and Apache-devel, respectively. For more RPM parameters, refer to the man rpm page:
2, *.tar.gz/*.tgz, *.bz2 form of binary package
Installation: Tar zxvf *.tar.gz or tar yxvf *.bz2
Uninstall: Delete manually
Note: Binary packages in *.tar.gz/*.bz2 form are packaged with the TAR tool, compressed with GZIP/BZIP2, and unpacked directly when installed. For only a single directory after decompression software, uninstall with the command "RM-RF software directory Name"; If the files are scattered in multiple directories, you must one by one manually delete (slightly troublesome), you want to know what files are installed to the system when extracting, you can use the command "tar ztvf *.tar.gz"/"tar YTVF *.bz2 "Get the list. The parameter z of TAR is called gzip decompression, X is unpacked, V is checksum, F is the display result, Y is called bzip2 decompression, and T is the list of files listing packages. For more parameters Please refer to man tar.
If you prefer the operation of the graphical interface, you can use KDE's Ark compression file management tool under X-window.

Well, for these two differences to look at it, their own mother, in fact, a lot of answers!

I use the 32-bit tar.gz form here, the reason I don't say more ...

2. Installing the JDK

Use the CP command to copy the downloaded Jdk-7u75-linux-i586.tar to the/OPT directory and view the content:

#cp jdk-7u79-linux-i586.tar.gz/opt/

Extract with decompression command: TAR-ZXVF jdk-7u79-linux-i586.tar.gz

# TAR-ZXVF Jdk-7u79-linux-i586.tar.gz

3. Once the decompression is complete, we will begin to configure the Global environment variables:

First enter the/etc/directory

#cd/etc/

To open the profile file with the VI Edit command:

#vi profile

Then add the following information at the end (insert information by pressing the I key):

After inserting, press escà:wq! write to save!

In order for the/etc/profile file to take effect immediately after modification, you can use the following command:

#. /etc/profile

Then use the source command to make the configuration effective:

#source/etc/profile

At this point, we are not far from success, now we only need to resume Java in the/sbin directory soft connection, SUN JDK1.7 installation tasks can be completed! What are you waiting for? Hurry up ...

At this point we enter the Java command in the shell and will hint that the Java command is not found in/usr/bin because we have not yet established a soft link for $java_home/bin/java in the/sbin directory.

So we just need to use LN to resume a soft connection:

# ln-s/opt/jdk1.7.0_67/bin/java/sbin/java

The installation of Sun JDK1.7 has been completed!

4.4. Test the JDK

After installing and configuring the environment variables, the next step is to test that the JDK is installed properly.

Enter Java-version or Javac-version, if the version information is displayed, the installation is successful:

#java –version

As you can see, the JDK has been installed successfully. Next, let's test a simple Hello xuhouwei! program:

(1) New T1.java file

(2) Add the following code:

Press escà:wq! write to save!

(3) Compile, run:

#javac T1.java

#java T1

As can be seen from the above, the JDK compiles and runs normally.

At this point, the installation of the JDK has ended successfully.

Very fortunate to be able to calm down to write this article, install the configuration process if there is a problem I hope you can contact me,

Sina Weibo: Http://www.weibo.com/suqianxushouwei

Blog Park: http://www.cnblogs.com/Jasxu/No.: Jasxu360

A brave man can make a miracle!




















CentOS 6.6 JDK1.7 Installation and configuration (Linux) Classic Introduction detailed case

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.