Thursday, December 23, 2010

Creating a Daemon-style Eclipse "headless" Application

A daemon application is an application that does not exit immediately and does not wait for any input/interaction from the user. Instead, it is (usually) providing a network service or by being a server. Apache Tomcat servlet container is one such daemon.

To run  a daemon-style application in Eclipse runtime, it is tempting to just use the standard infinite loop:


public class Application implements IApplication {

public Object start(IApplicationContext context) throws Exception {
// ... start services here (in another thread) ...
while (true) {
try {
} catch (InterruptedException e) {
return IApplication.EXIT_OK;

While this technique works, I believe the better way is just to immediately return normally. And use Eclipse's -noExit launch argument to let Eclipse know that we're still doing things in the background.

So the start() method can be just like this:

public Object start(IApplicationContext context) throws Exception {
final ResourceSetImpl resourceSet = new ResourceSetImpl();
Resource dealerResource = resourceSet
dealer = (YahooDealerImpl) dealerResource.getContents().get(0);


Resource catalogRes = resourceSet.createResource(URI.createFileURI("/home/ceefour/project/AbisPulsa/workspace/com.abispulsa.model/src/model/Catalog.xmi"));
Catalog catalog = (Catalog) catalogRes.getContents().get(0);

return IApplication.EXIT_OK;

Then edit the application's Launch Configuration and add the following to program arguments:

-noExit -consoleLog

You may also want to add the OSGi console (argument -console):

-noExit -consoleLog -console

Let's run 'em servers. :-)


  1. Great tip! Sometimes I find it's far simpler to just set osgi.noShutdown to true in my config.ini file, instead of relying on commandline options.

  2. We are consequently happy this particular internet point works and your post truly taught me to be. Will take a person on that home suggestions an individual

    RS Gold
    Buy RS Gold
    Cheap RS Gold
    Buy Cheap RS Gold
    Runescape Gold for Sale

  3. We had done a great number of orders with our customers for buying Runescape Gold fast and have hundreds of orders everyday .We are sure that you are impossible to get such an excellent service in buying Cheap Runescape Gold as the same as we Buy Runescape Gold.

  4. Very cool. I always enjoy the interviews. Thanks for having this blog

    RS Gold
    Cheap diablo 3 gold

  5. An advanced battle system lets you choose gw2 gold every cut, thrust, and swing in real time. Creative graphics plunge you into a world of adventure beauty. A massive fantasy world of warcraft based on over 75 years of books, movies, art, and music, developed in close cooperation with wow gold Conan Inc.

  6. Your AoE-Fear will be highly effective sufficient Buy Guild Wars 2 Gold, excellent to have people from stomps and to provide associates a few space, nah tbh this is the highly effective D3 Gems and 45sec would seem reasonable imo.

  7. DC Universe Online OnlineSony rsgold 2007 phase has begun registration to participate in the Legends PvP Tournament of the popular DC Universe Online for PC and PlayStation 3, in which heroes and villains from across Europe 07 runescape gold played a place to attend the event SOE Live from Las Vegas , where he held the great final.Para participate in this tournament, players have until June 24 to increase its ranking of Legends PvP in DC Universe Online, considering that the tournament is designed for old school runescape money teams of two.

  8. Nice article, thanks for the information. It's very complete information. I will bookmark for next reference
    jaring futsal | jaring golf | jaring pengaman proyek |
    jaring pengaman bangunan | jaring pengaman gedung