Linux installation Oracle JDK replacement OPENJDK detailed
Yang Posted in:2013-3-11 Category:Linux
As is known to all, due to the copyright issues of Oracle's JDK, most Linux distributions are installed with an open source openjdk with no copyright issues to support some Java program software. However, if we do some Java language development under Linux, it is likely that we will need to install and use the original Oracle JDK ("JDK"). How do I install the JDK and replace OpenJDK? Today Yang to do a detailed answer:
There is no doubt that if more than one JDK exists in a system at the same time, it can cause some problems and confusion. However, if you uninstall the openjdk of the system, it will cause some other software dependencies, that is, if uninstalling openjdk need to uninstall all other software that relies on openjdk, such as Openoffice/libreoffice. It's impossible to do this like this. So we can only install the JDK without deleting the openjdk, and then "replace" the original openjdk with the settings of some environment variables.
Before we start, let's java -version
look at the current system Java version by command:
Java version "1.6.0_24" OpenJDK Runtime Environment (IcedTea6 1.11.9) (rhel-1.57.1.11.9.el6_4-i386) OpenJDK Server VM ( Build 20.0-b12, Mixed mode)
As you can see, the current system is using the 1.6 version of OPENJDK, and below we begin to install the 1.7 version of the JDK.
First of all, of course, the Oracle official website to download the JDK installation package, the author download is jdk-7u10-linux-i586.rpm. After downloading, install it by using the following command:
[Email protected] ~]# RPM-IVH jdk-7u10-linux-i586.rpm
Next is the most critical configuration section, which modifies the environment variable profile/etc/profile to include the following lines of information at the end of the file: (where java_home=/usr/java/******, the actual installation path for the JDK)
Export Java_home=/usr/java/jdk1.7.0_10export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _ Home/lib/tools.jarexport path= $PATH: $JAVA _home/bin
So we've set up the JDK, and the final step is to modify the default JDK. That is to set the Java and Javac symbolic connection, which is to change the default openjdk1.6 to the newly installed jdk1.7. This can be done with the following two commands:
[[email protected] ~]# cd/usr/bin/[[email protected] bin]# ln-s-f/usr/java/jdk1.7.0_10/jre/bin/java[[email protected] bin]# ln-s-f/usr/java/jdk1.7.0_10/bin/javac
Finally, check to see if the changes have been successful. To execute the command again java -version
, the author shows the following content:
Java version "1.7.0_10" Java (tm) SE Runtime Environment (build 1.7.0_10-b18) Java HotSpot (tm) Server VM (Build 23.6-b04, mix Ed mode)
Visible and OPENJDK display before installation is different, the installation configuration is successful!
Please follow this Copyright agreement (use License), if you need to reprint please specify from the Yang Aberdeen blog.
Linux installation Oracle JDK replacement OPENJDK detailed