Friday 16 March 2012

How to run your java application as a service in Linux?

This problem is faced by many. You may want to run a java server application in any Linux server, but the only way you know to initialize and run this app is from the ssh terminal console. The problem here is, the application will stop , the moment you close your ssh terminal.

Whats the solution?   Just append an & at the end of the command.

Eg: For running hsql db as a service, am using the below command


java -cp ../hsqldb/lib/hsqldb.jar org.hsqldb.server.Server --database.0 file:appcache --dbname.0 appcachedb &


Now go ahead and close you ssh console. You will see that your db server is still running.

If you have a better way of doing this, do let me know.

Ajith.

1 comment:

John T said...

Nice tip...