How to auto start glassfish server

1. Create file name ‘glassfish’ and edit file

sudo nano /etc/init.d/glassfish

2. Write the lines below into the file and save it

#! /bin/sh

#to prevent some possible problems
export AS_JAVA=jdk path

GLASSFISHPATH= glashfish bin path

case "$1" in
echo "starting glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin start-domain domain1
$0 stop
$0 start
echo "stopping glassfish from $GLASSFISHPATH"
sudo -u glassfish $GLASSFISHPATH/asadmin stop-domain domain1
echo $"usage: $0 {start|stop|restart}"
exit 3

3. Make the init script file executable

sudo chmod a+x /etc/init.d/glassfish

4. Configure Glassfish for autostart on Ubuntu boot

sudo update-rc.d glassfish defaults

6. Start, stop or restart Glassfish server


service glassfish start


service glassfish stop


service glassfish restart

Adarsh Vengarathodi

Adarsh Vengarathodi is a serial entrepreneur and the CEO and founder of MistLayer, Inc. MistLayer is an ICT Company headquartered in San Francisco offering a full range of technology products, solutions, and services. MistLayer delivers innovative products that augment the lives of thousands of people around the world.

You may also like...