Installation instructions
System Environment: centos-6.3
Installation Method: rpm Installation
Software: jdk-7-linux-x64.rpm
: Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Preparations
(1) install centos with minimal installation.
(2) introduce the 163 source.
wget http://mirrors.163.com/.help/CentOS6-Base-163.repomv CentOS6-Base-163.repo CentOS-Base.repoyum makecache
(3) install common compilers and tools using yum
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel vim ntsysv
(4) Update centos
yum updateyum upgrade
When using the centos system, we may encounter a problem of inaccurate time. How can we solve this problem? Here we will teach you a method for time synchronization in the centos system, I hope you can solve your own problems.
Perform the following steps to synchronize time in the centos system:
The newly installed centos system server may be set incorrectly. You need to adjust the time zone and time.
The following is how the centos system uses NTP to synchronize data from a time server:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtimentpdate us.pool.ntp.org
Easy!
The first sentence is to change the current time zone to Shanghai, that is, the + 8 zone. If you want to change the other time zones, you can go to the/usr/share/zoneinfo directory;
The second sentence is to use ntpdate to synchronize the standard time.
If ntpdate is not installed, you can run Yum:
yum install -y ntpdate
Add scheduled tasks and synchronize the clock every 10 minutes
crontab -e0-59/10 * * * * /usr/sbin/ntpdate us.pool.ntp.org | logger -t NTP
In this way, we can solve the problem of inaccurate time in the centos system.
Check the original system version
[Root @ admin ~] # Java-version Java version "1.6.0 _ 24" Openjdk Runtime Environment (icedtea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64) Openjdk 64-bit server VM (build between 0-b12, mixed mode) |
To further view the JDK information:
[Root @ admin ~] # Rpm-Qa | grep Java Tzdata-java-2012c-1.el6.noarch Java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64 |
Uninstall openjdk and perform the following operations:
[Root @ admin ~] # Rpm-e -- nodeps tzdata-java-2012c-1.el6.noarch [Root @ admin ~] # Rpm-e -- nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64 |
Install JDK
Upload new jdk-7-linux-x64.rpm software to/usr/local/to perform the following operations:
[Root @ admin local] # rpm-IVH jdk-7-linux-x64.rpm |
JDK is installed in/usr/Java by default.
Verify Installation
Perform the following operations to check whether the information is normal:
[Root @ admin bin] # Java [Root @ admin bin] # javac [Root @ admin bin] # Java-versionJava version "1.7.0 _ 17" Java (TM) se Runtime Environment (build 1.7.0 _ 17-b02) Java hotspot (TM) 64-bit server VM (build 23.7-b01, mixed mode) |
Congratulations! The installation is successful!
Configure Environment Variables
After installing the jdk-7-linux-x64.rpm on my machine, I can still perform the javac and Java-version operations without configuring environment variables, so I didn't configure JDK environment variables. However, for future discomfort, we should record how to configure it as follows:
Modify the system environment variable File
Append the following content to the file:
Java_home =/usr/Java/jdk1.7.0 _ 17 Jre_home =/usr/Java/jdk1.7.0 _ 17/JRE Path = $ path: $ java_home/bin: $ jre_home/bin Classpath =.: $ java_home/lib/dt. jar: $ java_home/lib/tools. jar: $ jre_home/lib Export java_home jre_home path classpath |
Make the modification take effect
[Root @ admin local] # source/etc/profile // make the modification take effect immediately [Root @ admin local] # echo $ PATH // view the PATH value |
View system environment status
[Root @ admin ~] # Echo $ path /Usr/local/cmake/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin: /usr/sbin:/usr/bin:/usr/Java/jdk1.7.0/bin:/usr/Java/jdk1.7.0/JRE/bin:/root/bin |