How to setup Glassfish on ubuntu
May 1, 2009
NOTE: It has come to my attention that this starts glassfish with root privileges which wouldn’t be good if this wasn’t a test server! A alternative (and better method) can be found at link cheers Jasper.
* First you need to download the installer file from the glassfish website https://glassfish.dev.java.net/downloads/v2-b58g.html
which was glassfish-installer-v2-b58g.jar
* Next you need to decide where you want to install it… For example /usr/local/appname. So you will need to copy the install.jar to /usr/local (the jar will extract files into a glassfish folder).
* Next you follow the steps on the webpage above… so basically…
sudo -s
ENTER PASSWORD (Root Password)
java -Xmx256m -jar glassfish-installer-v2-b58g.jar
cd glassfish
chmod -R +x lib/ant/bin
lib/ant/bin/ant -f setup.xml
* Next you can either start it with the command
/usr/local/glassfish/bin/asadmin start-domain domain1
* Or better create a init.d file to start and stop it…
gedit /etc/init.d/glassfish
GLASSFISHPATH=/usr/local/glassfish/bin
case ”$1” in
start)
${GLASSFISHPATH}/asadmin start-domain domain1
;;
stop)
${GLASSFISHPATH}/asadmin stop-domain domain1
;;
restart)
${GLASSFISHPATH}/asadmin stop-domain domain1
${GLASSFISHPATH}/asadmin start-domain domain1
;;
*)
echo $”usage: $0 {start|stop|restart}”
exit 1
esac
* save and exit
* chmod a+x /etc/init.d/glassfish
* to have glassfish start during boot (and stop during halt)
ln -s /etc/init.d/glassfish /etc/rc1.d/K99glassfish
ln -s /etc/init.d/glassfish /etc/rc2.d/S99glassfish
Voila that’s it…
GWT
May 1, 2009
Examples on GWT
Extends popupPanel to create Tooltip
package com.javagwt.gwt.client;
(This can be vary according to your package structure.)
import com.google.gwt.user.client.*;
import com.google.gwt.user.client.ui.*;
import com.google.gwt.core.client.*;
public class GWTClient implements EntryPoint{
public void onModuleLoad() {
Label label = new Label();
label.setText(“label with tooltip”);
label.addMouseListener(new MouseListenerAdapter() {
public void onMouseEnter(Widget sender) {
ToolTip tip = new ToolTip(“this is a tooltip.”,0,0);
}
public void onMouseLeave(Widget sender) {
}
public void onMouseDown(Widget sender, int x, int y) {
}
public void onMouseUp(Widget sender, int x, int y) {
}
});
RootPanel.get().add(label);
}
}
class ToolTip extends PopupPanel{
final int VISIBLE_DELAY = 2000;
Timer removeDelay;
public ToolTip(String message, int x, int y){
super(true);
this.setPopupPosition(x, y);
this.add(new Label(message));
removeDelay = new Timer(){
public void run() {
ToolTip.this.setVisible(false);
ToolTip.this.hide();
}
};
removeDelay.schedule(VISIBLE_DELAY);
this.addPopupListener(new PopupListener(){
public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
removeDelay.cancel();
}
});
this.setStyleName(“toolTip”);
this.show();
}
public boolean onEventPreview(Event event){
int type = DOM.eventGetType(event);
switch(type){
case Event.ONMOUSEDOWN:
case Event.ONCLICK:{
this.hide();
return true;
}
}
return false;
}
}