JDBC Tutorials - Herong's Tutorial Examples - v3.13, by Herong Yang
Downloading and Installing JDK on Linux
This section provides a tutorial example on how to download and install JDK on Linux systems. The best way to install JDK on CentOS system is to the 'yum' package management tool.
Downloading and installing JDK on a Linux computer is more difficult for several reasons:
1. There are many variations and versions of Linux platforms running on different system architectures. So there is no single JDK package that works perfectly on all Linux platforms.
2. Oracle offers 3 binary packages for all Linux platforms with some installation instructions:
Package Platforms ------- ------- Linux Debian Package Debian Linux RPM Package Red Hat and SuSE Linux Compressed Archive Generic
3. OpenJDK offers a single generic binary package for all Linux platforms.
If you try to install the generic binary package on your specific Linux platform, you most likely will encounter some issues.
The best way to install JDK on your specific Linux platform is to use the package management tool on the system to search and automatically install the OpenJDK binary package that was built specifically for your platform.
Here is what did to on my CentOS system with the "yum" package management tool to search for openJDK, logging in as "root":
herong# yum search openJDK java-1.6.0-openjdk.i686 : OpenJDK Runtime Environment java-1.6.0-openjdk-devel.i686 : OpenJDK Development Environment java-1.6.0-openjdk-javadoc.i686 : OpenJDK API Documentation java-1.6.0-openjdk-src.i686 : OpenJDK Source Bundle ... java-1.8.0-openjdk.i686 : OpenJDK Runtime Environment java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle
So the latest version for my platform is OpenJDK 1.8, divided into several parts. To install JDK with compiler and other tools, I need to install java-1.8.0-openjdk.i686 and java-1.8.0-openjdk-devel.i686:
herong# yum install java-1.8.0-openjdk ... Installed: java-1.8.0-openjdk.i686 1:188.8.131.52.b09-1.el6_10 herong# yum install java-1.8.0-openjdk ... Installed: java-1.8.0-openjdk-devel.i686 1:184.108.40.206.b09-1.el6_10
Now verify the installation:
herong# java -version openjdk version "1.8.0_232" OpenJDK Runtime Environment (build 1.8.0_232-b09) OpenJDK Server VM (build 25.232-b09, mixed mode) herong# javac -version javac 1.8.0_232
Finally, set the JAVA_HOME environment variable, so other applications can find where JDK is installed. This can be done with an "export" command.
herong# export JAVA_HOME=/usr/lib/jvm/jre-1.8.0-openjdk.i386
Congratulations, you have successfully installed JDK on your Linux system!
Table of Contents