2.2.3. Configuring Your Java Environment

You must have a working installation of JDK 1.6 before you install JBoss Enterprise Portal Platform. You can install the 32-bit or 64-bit JVM as per your requirements. In this guide we will show you how to install a 32-bit Sun JDK 6.0 using RHN, on a generic Linux Platform and Microsoft Windows Platform. But before we do that let's take a look at some of the benefits of using a 64-bit JVM.

Benefits of 64-bit JVM on 64-bit OS and Hardware:

  • Wider datapath: The pipe between RAM and CPU is doubled, which improves the performance of memory-bound applications.
  • 64-bit memory addressing gives virtually unlimited (1 exabyte) heap allocation. However large heaps affect garbage collection.
  • Applications that run with more than 1.5 GB of RAM (including free space for garbage collection optimization) should utilize the 64-bit JVM.

Note

Applications that run on a 32-bit JVM and do not require more than minimal heap sizes will gain nothing from a 64-bit JVM. Barring memory issues, 64-bit hardware with the same relative clock speed and architecture is not likely to run Java applications faster than their 32-bit cousin.

Installing and Configuring JDK 6.0 using RHN

  • Java SDKs are provided by the Red Hat Enterprise Linux 5 Base and Supplementary channels for your Linux variant and architecture. The available JDKs corresponding to each channel and architecture are listed below:

    Red Hat Enterprise Linux 5 Java SDKs

    Channel: rhel-<arch>-server-5
    java-1.6.0-openjdk
    Channel: rhel-<arch>-server-supplementary-5
    java-1.6.0-sun (Sun)
    java-1.6.0-ibm (IBM)
    Ensure that the -devel packages are also installed.
  • Selecting alternatives for java, javac and java_sdk_1.6.0 (setting java_sdk_1.6.0 is optional).
    This is only needed if you want to use the SysV service script and/or want this installed SDK to be the default java and javac in the system. This choice can often be overridden by setting the JAVA_HOME environment variable.
    The alternatives system allows different versions of Java, from different sources, to co-exist on your system. You should make sure the desired one is selected so that the service script uses the one you want.
    As root, issue the following command:
    /usr/sbin/alternatives --config java
    and make sure the desired one is selected (marked with a '+'), or select it by entering its number as prompted.
    Make sure you do the same for javac and java_sdk_1.6.0. We recommend that all point to the same manufacturer and version.

Installing and Configuring JDK 6.0 on a generic Linux platform

  • Download the Java 2 Platform, Standard Edition (J2SE) Development Kit (JDK) 6.0 from Sun's website: http://java.sun.com/javase/downloads/index.jsp#need.
  • From this page, select the latest update under the Java Platform, Standard Edition heading. Alternatively, this page can be accessed directly at http://java.sun.com/javase/downloads/widget/jdk6.jsp.
  • Follow the instructions presented on this page including selecting the appropriate platform and architecture.
  • Clicking the Continue button will display the download options (depending on whether the user chooses to register):
    • jdk-6u<update number>-linux-<arch>-rpm.bin or;
    • jdk-6u<update number>-linux-<arch>.bin
    If installing the JDK on Red Hat Enterprise Linux, Fedora, or another RPM-based Linux system, it is recommended that the self-extracting file containing the RPM package is selected. This option will set up and use the SysV service scripts in addition to installing the JDK. The RPM option is also recommended if the JBoss Enterprise Portal Platform is being set up in a production environment.
  • Create an environment variable that points to the JDK installation directory and call it JAVA_HOME. Add $JAVA_HOME/bin to the system path to be able to run java from the command line. You can do this by adding the following lines to the .bashrc file in your home directory.
    #In this example /usr/java/jdk1.6.0_19 is the JDK installation directory.
    export JAVA_HOME=/usr/java/jdk1.6.0_19
    export PATH=$PATH:$JAVA_HOME/bin
    
    Set this variable for the user account performing the installation and also for the user account that will run the server.
  • If you have more than one version of JVM installed in your machine, make sure you are using the JDK1.6 installation as the default java and javac. You can do this using the alternatives system. The alternatives system allows different versions of Java, from different sources to co-exist on your system.

    Note

    Selecting alternatives as decribed below can be avoided by setting the JAVA_HOME environment variable as explained in the previous step.

    Select alternatives for java, javac and java_sdk_1.6.0

    • As root, type the following command at the shell prompt and you should see something like this:
      [root@vsr ~]$ /usr/sbin/alternatives --config java
      There are 2 programs which provide 'java'.
      Selection    Command
      -----------------------------------------------
         1           /usr/lib/jvm/jre-1.4.2-gcj/bin/java
      *+ 2           /usr/lib/jvm/jre-1.6.0-sun/bin/java
      Enter to keep the current selection[+], or type selection number:
      
      
      Make sure the Sun version - jre-1.6.0-sun in this case - is selected (marked with a '+' in the output), or select it by entering its number as prompted.
    • Repeat the same for javac and java_sdk_1.6.0.
      [root@vsr ~]$ /usr/sbin/alternatives --config javac
      There are 1 programs which provide 'javac'.
      	Selection   Command
      -----------------------------------------------
      *+ 1           /usr/lib/jvm/java-1.6.0-sun/bin/javac
      Enter to keep the current selection[+], or type selection number:
      
      [root@vsr ~]$ /usr/sbin/alternatives --config java_sdk_1.6.0
      There are 1 programs which provide 'java_sdk_1.6.0'.
      	Selection   Command
      -----------------------------------------------
      *+ 1           /usr/lib/jvm/java-1.6.0-sun
      Enter to keep the current selection[+], or type selection number:
      
      You should verify that java, javac and java_sdk_1.6.0 all point to the same manufacturer and version.
  • Make sure that the java executable is in your path and that you are using an appropriate version. To verify your Java environment, type java -version at the shell prompt and you should see something like this:
    [root@vsr ~]$ java -version
    java version "1.6.0_19"
    Java(TM) SE Runtime Environment (build 1.6.0_19-b01)
    Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)
    

Installing and Configuring JDK 6.0 on Microsoft Windows

  • Download the Java 2 Platform, Standard Edition (J2SE) Development Kit (JDK) 6.0 from Sun's website: http://java.sun.com/javase/downloads/index.jsp#need.
  • From this page, select the latest update under the Java Platform, Standard Edition heading. Alternatively, this page can be accessed directly at http://java.sun.com/javase/downloads/widget/jdk6.jsp.
  • Follow the instructions presented on this page including selecting the appropriate platform and architecture.
  • Clicking the Continue button will display the download option (depending on whether the user chooses to register):
    • jdk-6u<update number>-windows-<arch>.exe
  • Create an environment variable called JAVA_HOME that points to the JDK installation directory, for example: C:\Program Files\Java\jdk1.6.0_19\.
  • In order to run java from the command line add the jre\bin directory to your path, for example: C:\Program Files\Java\jdk1.6.0_19\jre\bin. You may set these variables by going to the System Properties window then select the Advanced tab and finally click on the Environment Variables button.