Environment configuration for JDK in CentOS

Source: Internet
Author: User

In CentOS, the configuration of the JDK environment, this is still frustrating I listen to a long time. In particular, in a single configuration, resulting in my root user will not be able to log in, and with other ordinary users to log on, using su-root switch to the root user, can not use LS this ordinary commands. Because of the lack of permissions, all kinds of changes are not. So, reinstall the CentOS system again, all kinds of trouble ah ~
This time reconfigure again, using the method is not the same, incredibly feasible.
The configuration steps are as follows (I am using a normal user login):
1. First, we need to get ready: Download the JDK, this to the official network, for the Linux system, there are two kinds of official online: one is tar.gz, and the other is. rpm. Both of these are possible. Both of these need to be decompressed, and the commands used are not the same.
2. Use Su-root to switch to the root user. Unzip the JDK, the path I unzipped is/usr/java. If it is in tar format, use tar zxvf * * * to decompress. If it is. RPM, then we need to use RPM-IVH * * to decompress. (i downloaded the latest version of the JDK, 7u21, after decompression, the path to the JDK bin is:/usr/java/jdk1.7.0_21)
3. Then, go to/etc, using the VI Profile command, append the environment variables to the profiles: (The last failure was configured and saved in ROOT/BASHRC, although the Java command can be used, but the root user cannot log in, and LS Such a command can not be used. Then under the ordinary user, the SU switch to the root user, using the Echo $PATH, output content, there is no/usr/bin this. I do not know where the problem appears, according to the changes on the Internet, changed for a long time, also did not make a what. Can only say, their qualifications are general, do not understand AH ~)
Export java_home=/usr/java/jdk1.7.0_21
Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Export path= $PATH: $JAVA _home/bin
4. Save and execute source/etc/profile.
5. On the command line, enter java-version to install the JDK version. (In my system, there is no default JDK that comes with it)

PS. This command can only be used under the login user, if you want to use under other users, you may log on to a user, perform a source/etc/profile can be used.

Environment configuration for JDK in CentOS

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.