| From | Sent On | Attachments |
|---|---|---|
| Christopher Brown | Mar 16, 2007 2:30 am | |
| Mark A Fortner | Mar 16, 2007 9:56 am | |
| Christopher Brown | Mar 16, 2007 2:40 pm | |
| Hans Muller | Mar 28, 2007 4:48 pm | |
| Steven Coco | Mar 28, 2007 9:45 pm | |
| Rene...@blum.com | Mar 28, 2007 10:01 pm | |
| Christopher Brown | Mar 29, 2007 1:08 am | |
| Vity | Mar 29, 2007 12:18 pm | |
| ed-tidwell | Mar 29, 2007 12:37 pm | |
| Steven Coco | Mar 29, 2007 12:47 pm | |
| Ian Darwin | Mar 29, 2007 1:02 pm | |
| Ed Tidwell | Mar 29, 2007 3:55 pm | |
| Rene...@blum.com | Mar 29, 2007 10:04 pm | |
| Christopher Brown | Mar 30, 2007 1:08 am | |
| Peter Weishapl | Mar 30, 2007 1:38 am | |
| Ed Tidwell | Mar 30, 2007 5:50 am | |
| Hans Muller | Apr 3, 2007 8:04 am | |
| Hans Muller | Apr 3, 2007 2:21 pm | .java, .properties |
| Hans Muller | Apr 3, 2007 2:35 pm | |
| Rene...@blum.com | Apr 3, 2007 9:42 pm | |
| Hans Muller | Apr 4, 2007 8:36 am | |
| Andy Herrick - Java Engineering | Apr 4, 2007 9:59 am |
| Subject: | Java Web Start SingleInstanceService | |
|---|---|---|
| From: | Hans Muller (Hans...@Sun.COM) | |
| Date: | Apr 3, 2007 2:21:26 pm | |
| List: | net.java.dev.appframework.users | |
| Attachments: | ||
[Subject was: Re: Antwort: Re: Desktop class and SystemTray class in Java 6]
Java Web Start ostensibly supports launching a single instance of an application via javax.jnlp.SingleInstanceService. The second and subsequent web start launches of an application just run a listener (SingleInstanceListener) installed by the first copy of the app to notify it about the new command line arguments.
This scheme hinges on what identifies an application. By default the ID appears to be the URL specified by the href attribute of the JNLP element. This would appear to hamstring the whole scheme, since the only way to launch another copy of the same application - with different arguments - would be to dynamically generate a new version of the JNLP file.
Fortunately it appears that if the href attribute is not specified, then the identity of the application becomes the URL for the jar file that contains the main class. That means that one can have a bunch of JNLP files that launch the same application, but with different arguments. I've attached the source code for such an application (written against an as-yet unreleased version of the application framework). The demos just show an image, using the LoadImageTask from the application.examples package. They're different photos of old-time race cars taken by Jasper Potts.
The JNLP files are: http://download.java.net/javadesktop/appframework/singleinstancedemo/showcar1.jnlp http://download.java.net/javadesktop/appframework/singleinstancedemo/showcar2.jnlp http://download.java.net/javadesktop/appframework/singleinstancedemo/showcar3.jnlp
One problem with this scheme: Web Start uses the href attribute to check if a newer version of the JNLP file is available. By removing it (the href attribute) we're defeating that mechanism. This is relatively easy to work around and I've asked the JWS group about it.
Also: I've compiled this with Java SE 6 and have not tried it on OSX.
- Hans
Peter Weishapl wrote:
I can't believe this problem isn't already solved! how does eclipse, netbeans or webstart do it?
On 30.03.2007, at 10:09, Christopher Brown wrote:
I agree that the socket route can sometimes (in locked-down environments) be troublesome, but what happens with a lockfile if the JVM (or OS) aborts without deleting it? I prefer writing and frequently rewriting lockfiles with current time as a way of determining if the lockfile is current or hanging around after a crash. I don't like asking end-users to delete the file.
I suggest making the single-instance detection pluggable (I don't like "pluggability overkill" but there seems to be a requirement here given advantages and disadvantages of this approach.
Pity we didn't have the Isolates API / MVM for this...
- Chris
On 29/03/07, ed-tidwell <ed-t...@carolina.rr.com> wrote: Rene,
Socket resources are usually monitored a lot more these days. This is a good idea and will work. The only problem is what if two users want to use the same machine and application?
Common in the Unix world to rlogin and export the display. More common now in XP as well it two users login.
I think it might be better to go with a .app file in the users home directory. Then this file can be used for two things. You can see if this user is running it on this machine. (add the IP or machine name to the file)
The other advantage is if your application crashes you can let the user know about it and possible recover state from any temp files laying around.
With all of the security applications that pop up a dialog where the user has to allow the socket connection the internal IP messaging route might be more trouble than it is worth in certain environments.
Cheers, Ed Tidwell






.java, .properties