Tuesday, February 5, 2008

Java

  • Fedora Core provides an open source implementation of Java. See http://fedora.redhat.com/docs/release-notes/fc5/test3-latest-en/#sn-Java for information about this. However many users, myself included, prefer Sun Java for their purposes. To install Sun Java open Firefox, go to http://java.sun.com/j2se/1.5.0/download.jsp, click on Download JRE 5.0 Update 8, click the radio button to accept the license agreement, under "Linux Platform - J2SE(TM) Runtime Environment 5.0 Update 8" click on "Linux self-extracting file", to download jre-1_5_0_08-linux-i586.bin (save to disk). This should save the file to your home folder. If it saves the file to your desktop instead go to your desktop and drag the file into your "Home" folder. (Left mouse click on the file and drag it on top of your "Home" folder while holding the left mouse button down. Then release the mouse button.)
  • If you have not already done so go to "System" > "Administration" > "Security Level and Firewall". Enter your root password and click "ok". On the "SELinux" tab click on "Modify SELinux Policy", click on "Compatibility" to open it and tick the check box next to "Allow the use of shared libraries with Text Relocation". Click "ok". Reboot your machine to implement the new SELinux policy.
  • Open a terminal. Type:
    su
    Hit enter. Type your root password. Hit enter.
  • Type:
    mv *.bin /opt
    Hit enter.
  • Type:
    cd /opt
    Hit enter.
  • Type:
    chmod +x *-linux-i586.bin
    Hit enter.
  • Type:
    ./*.bin
    Hit enter. Hold the enter key down until the yes/no line appears to allow you to agree to the license agreement. Type "yes" and hit enter. Wait for the installation to complete.
  • Type:
    rm *.bin
    Hit enter. Type "y" and hit enter.
  • Type:
    su -
    Hit enter. This gives you root privileges and also puts you in the /root directory.
  • Type:
    ln -s /opt/jre1.5.0_08/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so
    (Note that by default Firefox looks in /usr/lib/mozilla/plugins for its plugins. If you have trouble with your plugins in Firefox you could substitute "firefox-1.5.0.1" or your most recent firefox directory name in place of "mozilla" in the above command.) Hit enter. Close the terminal. Restart Firefox to enable the java plugin. You could go to http://www.java.com/en/download/help/testvm.xml to test your java plugin installation.

    (If you wish to install the JDK which includes the Java development environment rather than the JRE download the JDK .bin file from Sun instead of the JRE .bin file, substitute "jdk1.5.0_08" for "jre1.5.0_08" in the commands above and below and use "ln -s /opt/jdk1.5.0_08/jre/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so" rather than "ln -s /opt/jre1.5.0_08/plugin/i386/ns7/libjavaplugin_oji.so /usr/lib/mozilla/plugins/libjavaplugin_oji.so" to create the browser plugin.)

    We are not done with Java quite yet, even though your browser plugin is working. Please proceed to the next step.

  • If you wish to run Java applications such as LimeWire, JAlbum or Azureus and you have installed the Sun J2SE JRE into /opt as described above, open a terminal and type:
    su -
    Hit enter. Type your root password. Hit enter.
  • Type:
    gedit /etc/profile.d/java.sh
    Hit enter.
  • In gedit type or copy and paste these lines:
    export J2RE_HOME=/opt/jre1.5.0_08
    export PATH=$J2RE_HOME/bin:$PATH

    Be sure to enter a carriage return after these lines. Click on the "save" icon in gedit and exit gedit.
  • In the terminal (which should still be open) type:
    source /etc/profile.d/java.sh
    Hit enter.
  • Type:
    which java
    Hit enter.
  • You should see:
    /opt/jre1.5.0_08/bin/java
  • Type:
    /usr/sbin/alternatives --install /usr/bin/java java /opt/jre1.5.0_08/bin/java 2
    Hit enter.
  • Type:
    /usr/sbin/alternatives --config java
    Hit enter.
  • You should see:
    There are 2 programs which provide 'java'.

    Selection Command
    -----------------------------------------------
    * 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
    + 2 /opt/jre1.5.0_08/bin/java

    Enter to keep the current selection[+], or type selection number:
  • Type:
    2
    Hit enter.
  • Type:
    /usr/sbin/alternatives --display java
    Hit enter.
  • You should see:
    java - status is manual.
    link currently points to /opt/jre1.5.0_08/bin/java
    /usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1420
    slave rmiregistry: /usr/lib/jvm/jre-1.4.2-gcj/bin/rmiregistry
    slave jre_exports: /usr/lib/jvm-exports/jre-1.4.2-gcj
    slave jre: /usr/lib/jvm/jre-1.4.2-gcj
    /opt/jre1.5.0_08/bin/java - priority 2
    slave rmiregistry: (null)
    slave jre_exports: (null)
    slave jre: (null)
    Current `best' version is /usr/lib/jvm/jre-1.4.2-gcj/bin/java.
    You should now be able to install and run Java applications.

No comments: