2.2. Configuring Java

There are two basic ways to configure the system for the OpenJDK. Neither option is necessary if the java-1.6.0-openjdk is the only version of Java installed on the system.

Procedure 2.1. Setting the Java and Javac Variables

  1. Open a terminal.
  2. As the superuser, call /usr/sbin/alternatives with the --config java option.
    A list of options should appear similar to the one below:
    home]$ sudo /usr/sbin/alternatives --config java
    
    There are 2 programs which provide 'java'.
    
      Selection    Command
    -----------------------------------------------
    *+ 1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
       2           /usr/lib/jvm/jre-1.6.0-gcj/bin/java
    
    Enter to keep the current selection[+], or type selection number:
    Enter the number corresponding with the jre-1.6.0-openjdk and press enter.
  3. Repeat the process for --config javac.

Procedure 2.2. Setting the JAVA_HOME Environment Variable

  1. Open a terminal.
  2. Append the following line to the ~/.bashrc file:
    export JAVA_HOME="/usr/lib/jvm/jre-1.6.0-openjdk.x86_64"
  3. Execute the command source ~/.bashrc.
  4. Check to see if JAVA_HOME is set to the correct location:
    ~]$ echo $JAVA_HOME
    The output should look like this:
    ~]$ echo $JAVA_HOME
    /usr/lib/jvm/jre-1.6.0-openjdk.x86_64

Note

The changes to the ~/.bashrc file should also be applied for other users who will be running JBCP on the machine (any environment variables exported from ~/.bashrc are local to that user).