Here's some in-a-nutshell information on how to deal with Java on Ubuntu server 8.10:
To find out what's on an Ubuntu system for Java:
$ update-java-alternatives -l
Running
$ java -version
shows that the OpenJRE 6 is installed by default. Aha, it's a JRE. To install and probably run Glassfish, however, you need a JDK. Off we go and install it with:
$ sudo apt-get install sun-java6-jdk
(and get demo, doc, source, too, while you're at it)
Ok, but now, how to make this JDK the default Java on the machine. Some tools are available, fortunately, and without much background research, we make use of them to make the switch:
$ sudo update-java-alternatives -s java-6-sun
Now, calling
$ java -version
shows Sun's java to be active.
Now you can download Glassfish, install and configure it. That's very well documented already.