Install Oracle Java 7 on Ubuntu:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-set-default
Install Glashfish 4 on Ubuntu:
#Download Glassfish 4
wget download.java.net/glassfish/4.0/release/glassfish-4.0.zip
#install the unzip program
apt-get install unzip
#unzip the glassfish zip to you /opt directory
unzip glassfish-4.0.zip -d /opt
#start glassfish app server
/opt/glassfish4/bin/asadmin start-domain
#change the admin password (the current/default is blank):
/opt/glassfish4/bin/asadmin change-admin-password
#enable remote access to the admin console
/opt/glassfish4/bin/asadmin enable-secure-admin
#restart the domain
/opt/glassfish4/bin/asadmin restart-domain