Thursday, August 7, 2008

The ONLY reliable JDK + JRE

Fedora 8 comes with the bug-ridden IcedTea implementation of JRE with so-called version number 1.7 !! Although this means that you have a pre-installed JRE, it is not recommended to use this package. Instead, install the JDK+JRE provided on the official NetBeans DVD (if you are a hardcore programmer, and use NetBeans like MS Office :D) or download the JRE from Sun's official website: http://java.sun.com

NOTE: Use only Sun's JDK + JRE. Do not use any other implementations.

Fix for JRE/JDK error in Fedora 8

Problem: JRE/JDK fails to install

Error message: Assertion 'c->xlib.lock' failed

Diagnosis: The file libmawt.so has a known bug that needs to be fixed

Solution:

  1. Check if the JDK in question is visible throughout the system. For that, execute $ /usr/sbin/alternatives --config java
  2. If JDK 1.6 is not present, but you are sure you have installed it, execute this: $ /usr/sbin/alternatives/ --install /usr/bin/java java /usr/java/jdk1.6.0_03/jre/bin/java 3
  3. Copy paste the following code into a plain text file & save it with the extension '.sh' in any folder of your choice
  4. Right-click on the file. Select Properties > Permissions > Allow executing file as program (Enable)
  5. Close the dialog
  6. Double-click the file. Select "Run in Terminal"

#!/bin/sh
# S. Correia
# 2007 11 21
# A simple script to patch the java library in order
# to solve the problem with "Assertion 'c->xlib.lock' failed."
# see bug http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6532373
LIB_TO_PATCH=libmawt.so
for f in `find /usr/java/jdk1.6.0_03/jre/ -name "$LIB_TO_PATCH"`
do
echo "Patching library $f"
sudo sed -i 's/XINERAMA/FAKEEXTN/g' "$f"
done

Points to note:

  1. The patch will work on "as is" basis only for Fedora 8, while trying to install JRE/JDK 1.6 from the NetBeans DVD. For other OSs / JREs, please modify the path: "/usr/java/jdk1.6.0_03/jre/ " given in the file to point to the directory where the JRE is installed
  2. The file libmawt.so is present in multiple locations in a JRE and hence, finding each file and patching it manually is not recommended