3. Installing Java

Find yourself a mirror for the BlackDown Java Development Kit at:

  http://www.blackdown.org/java-linux/mirrors.html

There you can download the latest versions of the J2 Software Development Kit (SDK) and Run-time Engine (RE).

Make sure you pick out the right version for the gcc library installed on your system. You can find out the version currently installed by typing:

  
  rpm -q libgcc
  
  

Installation instructions for the Java Development Kit are available as INSTALL-j2sdk and INSTALL-j2re.

Make the binary distribution of the SDK executable and extract in a new directory:

  
  chmod +x j2sdk-xxx.bin
  cd /usr/local/
  .../j2sdk-xxx.bin
  
  

Change the ownership of the J2SDK directory and make it available as /usr/local/j2sdk/:

  
  chown -R root:root /usr/local/j2sdk-xxx/
  ln -s /usr/local/j2sdk-xxx /usr/local/j2sdk
  
  

Do the same for the RE:

  
  chmod +x j2re-xxx.bin
  cd /usr/local/
  .../j2re-xxx.bin
  chown -R root:root /usr/local/j2re-xxx/
  ln -s /usr/local/j2re-xxx /usr/local/j2re
  
  

Since we didn't install the JDK and RE in our path, we have to add the bin/ directories to our $PATH environment variable. To make sure the Java distributions and classes can be found, we set the $JAVA_HOME and $CLASSPATH variables as well.

For the Bourne shells, create a file /etc/profile.d/java.sh:

  
  if ! echo ${PATH} | grep -q /usr/local/j2sdk/bin ; then
    export PATH=/usr/local/j2sdk/bin:${PATH}
    fi
  if ! echo ${PATH} | grep -q /usr/local/j2re/bin ; then
    export PATH=/usr/local/j2re/bin:${PATH}
    fi
  export JAVA_HOME=/usr/local/j2sdk
  export CLASSPATH=.:/usr/local/j2sdk/lib/tools.jar:/usr/local/j2re/lib/rt.jar
  
  

Set its ownership and access rights:

  
  chown root:root /etc/profile.d/java.sh
  chmod 755 /etc/profile.d/java.sh
  
  

Do the same for C shells, by creating the file /etc/profile.d/java.csh:

  
  if ( "${path}" !~ */usr/local/j2sdk/bin* ) then
    set path = ( /usr/local/j2sdk/bin $path )
    endif
  if ( "${path}" !~ */usr/local/j2re/bin* ) then
    set path = ( /usr/local/j2re/bin $path )
    endif
  setenv JAVA_HOME /usr/local/j2sdk
  setenv CLASSPATH :/usr/local/j2sdk/lib/tools.jar:/usr/local/j2re/lib/rt.jar
  
  

and setting its ownership and access rights:

  
  chown root:root /etc/profile.d/java.csh
  chmod 755 /etc/profile.d/java.csh
  
  

Now the JDK should be available to everyone on your system.

Tip

You can test the Java engine by typing:

  
  java -version
  
  

or create a file Test.java:

  
  public class Test {
    public static void main(String[] args) {
      System.out.println("Hello world");
      }
    }
  
  

and test the compiler:

  
  javac Test.java
  java Test