Recent Posts

RSS Feeds

Debian 4 Sun Java 6 JDK install problem solved

If you want to start your Grails or Java web application on a virtual private server (VPS) with Debian 4 (Etch) Linux you may run into the same Sun Java JDK 6 installation problem as I did. Here's my solution:

Deactivating Java class sharing in postinstall script

If you install the Sun Java JDK 6 on a Debian system via Debians package manager via

# apt-get install sun-java6-jdk

you'll get it installed but not configured. Configuration is automatically started after installation and fails on VPS with an error message. The reason behind this is a really sophisticated post installation script which wants to do you a favour and activate a feature of the Sun JDK called Java class sharing. This is a caching mechanism to reduce the startup time for Java applications. Since a web based Java application runs inside a Java web container and this container is only started once at server boot time optimization of the Java startup time is of no value for you. So we are gonna skip this step since it won't work as supposed anyways. Open the script found under:

/var/lib/dpkg/info/sun-java6-bin.postinst

Uncomment the following lines:

    # activate class data sharing
    case i386 in i386|sparc)
        rm -f $basedir/jre/lib/i386/client/classes.jsa
        xmarg=$(awk '/^((Mem|Swap)Free|Cached):/ { m+=$2 } END { if (m > 1048576
) print "-Xmx1m" }' /proc/meminfo 2>/dev/null || true)
        log=$(tempfile)
        if ! $basedir/bin/java -client -Xshare:dump $xmarg -XX:PermSize=128m >
$log; then
        if ! $basedir/bin/java -client -Xshare:dump -Xx128m -XX:PermSize=128m >
 $log; then
            cat >2 $log
            rm -f $log
            exit 1
        fi
        rm -f $log
    esac

The method to calculate the main memory would fail anyway since /proc/meminfo reports the total memory of the VPS host machine, not the part your VPS slice has available. This is only reported in the /proc/user_beancounters pseudo  text file.

If you are using Sun JDK 5 on Debian 4 I described a similiar solution in an older blog post from me.

  Share

Permalink    

Related Articles:

Senden Sie einen Kommentar:
Kommentare sind ausgeschaltet.