If you want to compile SWI-Prolog for your system yourself you could also use the new 5.11.X version.
Download the sources here: http://www.swi-prolog.org/download/devel
Be sure that you installed all necessary libraries on your system. You can use the following apt-get command:
sudo apt-get install binutils coreutils gcc grep libc6-dev libgmp3-dev libncursesw5-dev libreadline5-dev autoconf make sed curl chrpath unixodbc-dev libxext-dev libice-dev libjpeg62-dev libxinerama-dev libxft-dev libxpm-dev libxt-dev pkg-config libssl-dev zlib1g-dev
Don't use OpenJDK. To avoid a lot of problems you should stay with the original Java version from Sun/Oracle
If you are running Ubuntu 10.4 this can be done by:
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" sudo apt-get install sun-java6-jdk
Be sure to uninstall OpenJDK first.