views:

203

answers:

2

I developed small cross-platform (Windows and Mac) SWT desktop application. It is distributed with WebStart. So far so good, everything works.

I've got a new requirement to make my app start on system startup (with no user interaction). What is the best way to accomplish that?

In JNLP file I've got this:

<shortcut online="false">
    <desktop/>
    <menu submenu="CompanyName"/>
</shortcut>

On Windows WebStart creates a desktop link [app_name].lnk and it points to javaws.exe and then some Java cache file as a parameter with funny name like ..\Sun\Java\Deployment\cache\6.0\4\2c0a6a781-213476. I can possibly programmatically find that link on user's machine by name... erm... and then copy it into user's Startup folder. I can see a problem here though as user can disable WebStart desktop shortcut creation option all together.

On Mac WebStart pops up a dialog to prompt user for the location where to create an [app_name].app (user is allowed to change link name there!) file that launches an application. On Mac I don't event know where the Startup folder is located (and it seems to be much more complex there).

Is there Java library out there that abstracts start app on system startup concept on different platforms as SWT does for GUI abstraction?

A: 

There is, but it's very new, so it's not widely available.

The IntegrationService was introduced in 1.6.0u18. The method of interest is [requestShortcut][2].

[2]: http://java.sun.com/javase/6/docs/jre/api/javaws/jnlp/javax/jnlp/IntegrationService.html#requestShortcut(boolean, boolean, java.lang.String)

Devon_C_Miller
I don't see anything related to *application autostart on system startup* in there, was it a right link?
parxier
+1  A: 

You can take a look at Java Service Wrapper. This can wire your program as a windows service.

Samuel Yung