You need to write a shell script and add it to /etc/init.d, and you need to set run level (how you do that varies slightly between different Linux flavors - most of them provide GUI tools for doing this).
JBoss AS comes with several such scripts, you could use one of those as a template.