CentOS 6.4 - Install Oracle Java 1.7 JDK

    Here is a script to automate the entire process on a 64bit CentOS OS. You can just upload this to your server, and run it as root. Be sure to read through the oracle licence agreement. The steps after this explain how to do this manually, allowing you to perform the install for 32 bit OS as well as how to set up the browser plugins.

    #!/bin/bash
    # Installs the Sun JRE 1.7.4 on a Centos 6.x 64bit OS and does not include the browser plugin steps
    # Please refer to http://programster.blogspot.co.uk/2013/06/centos-64-install-oracle-java-17-jdk.html
    export DIRECTORY='technostu_install_java'
    cd ~
    mkdir $DIRECTORY
    cd $DIRECTORY
    
    # Download the JRE
    wget http://www.technostu.com/public_files/oracle/java/jdk/64/jdk-7u40-linux-x64.rpm
    
    # Install the rpm
    rpm -Uvh jdk-7u40-linux-x64.rpm
    
    # Update the aliases/alternatives
    echo 'Updating alternatives....'
    alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
    alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000
    alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
    alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 20000
    
    echo 'cleaning up....'
    # Remove all the temporary stuff we downloaded
    cd ~
    rm -rf $DIRECTORY
    echo 'done!'
    [Raw]
    Go here and download the relevant rpm (you will need to agree to their licence agreement).
    Upload the file to your CentOS server
    Install the rpm (make sure my filename matches your's as mine may be out of date by the time you read this)
    rpm -Uvh /path/to/binary/jre-7u7-linux-i586.rpm
    alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
    alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000
    alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
    alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 20000
    Optional for those that are running browsers in 32bit os
    alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 20000
    Optional for those that are running browsers in 64bit os
    alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 20000
    If you try java --version and it states that it failed to start the virtual environment, don't panic! It did this for me but could still run my .class files.

References

No comments:

Post a comment