Technical Recipes

How to install Oracle JDK 7 on CentOS

Alternatively, if you prefer to install Oracle JDK, there is no download available in the Linux repository. But you can manually download the it from Oracle website and manually install it.
 
1. Download the Java Development Toolkit .rpm package from Oracle website
 
    http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
 
    32-bit Version: jdk-7u<version>-linux-i586.rpm
    64-bit Version: jdk-7u<version>-linux-x64.rpm
 
2. Install the package for 64-bit
 
    # rpm -Uvh /path/to/package/jdk-7u<version>-linux-x64.rpm
 
3. Configure the system to use Oracle Java
 
    1) Set java
 
        # alternatives --install /usr/bin/java java /usr/java/jdk-7u<version>/jre/bin/java 20000
 
    2) Set javaws (optional for server)
 
        # alternatives --install /usr/bin/javaws javaws /usr/java/jdk-7u<version>/jre/bin/javaws 20000
 
    3) Set javaws (optional for development)
 
        # alternatives --install /usr/bin/javac javac /usr/java/jdk-7u<version>/bin/javac 20000
        # alternatives --install /usr/bin/jar jar /usr/java/jdk-7u<version>/bin/jar 20000
 
4. Verify the installed Java version
 
    # java -version
    
5. Find where JVM is ins

	# alternatives --display java
	# which java

6. Uninstall package

	# rpm -e <package_name>