Thursday, June 14, 2012

Install JDK 6 in CentOS 5.5




[root@www jvm]# wget --no-cookies --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk6-downloads-1637591.html;" http://download.oracle.com/otn-pub/java/jdk/6u33-b03/jdk-6u33-linux-x64-rpm.bin


[root@www jvm]# mv jdk-6u33-linux-x64-rpm.bin\?AuthParam\=1339658940_4918ae55fd15b9077dd6590269b247c6  jdk-6u33-linux-x64-rpm.bin


[root@www jvm]# sh ./jdk-6u33-linux-x64-rpm.bin
Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jdk-6u33-linux-amd64.rpm
  inflating: sun-javadb-common-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-core-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-client-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm
  inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
Installing JavaDB
Preparing...                ########################################### [100%]
   1:sun-javadb-common      ########################################### [ 17%]
   2:sun-javadb-core        ########################################### [ 33%]
   3:sun-javadb-client      ########################################### [ 50%]
   4:sun-javadb-demo        ########################################### [ 67%]
   5:sun-javadb-docs        ########################################### [ 83%]
   6:sun-javadb-javadoc     ########################################### [100%]

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Oracle products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the JDK Product Registration form will
be presented. If you do not register, none of this information
will be saved. You may also register your JDK later by
opening the register.html file (located in the JDK installation
directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....


Done.

[root@www jvm]# rpm -Uvh jdk-6u33-linux-amd64.rpm
Preparing...                ########################################### [100%]
        package jdk-1.6.0_33-fcs.x86_64 is already installed

# sh ./jre-6u30-linux-i586-rpm.bin
# alternatives --config java
There are 2 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
Enter to keep the current selection[+], or type selection number:

Note number of versions, N, and use N+1 (if there is no output from the previous command, just imagine that N=0) - For example, if 2 versions were installed then:
# alternatives --install /usr/bin/java java /usr/java/latest/bin/java 3
# alternatives --config java
There are 3 programs which provide 'java'.
  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
   3           /usr/java/latest/bin/java
Enter to keep the current selection[+], or type selection number: 3
# java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30)
Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing)



For jre;

export JAVA_HOME="/usr/java/jre1.6.0/bin"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME"

For jdk;

export JAVA_HOME="/usr/java/jdk1.6.0/jre/bin"
export JAVA_PATH="$JAVA_HOME"
export PATH="$PATH:$JAVA_HOME"


When done creating or editing the file type; 

source /etc/profile.d/java.sh

Now any user root or other wise should be able to use the command;

which java

and the results should read something like;

/usr/bin/java


PS: If you want to load the environment variables within java.sh without having to restart the machine, you can use the source command as in:
$> source java.sh


1 comment:

Jeff said...

Great tip on using wget that way - thanks!