• Post Reply Bookmark Topic Watch Topic
  • New Topic

Another reason to want to restart java from java  RSS feed

 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought a new thread was warranted because my situation is a bit different.

I have only been thinking about this and haven't started to implement it yet. I have several programs that check if an update is available. Right now they just tell you and it's your job to download an unpack the jars.

It would be kind of cool if it behaved like Firefox or TBird and downloaded the archive in the background then popup a dialog and say you have to restart to get the new version, press this button to do it now.

I'm wondering how others do that? I'm not comfortable overwriting jar files of a running program. I can think of a few possibilities but would like to hear about something that has worked before.

Thanks,
Joe
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
While restarting a native app (like Firefox) is probably necessary to pick up updates, in Java you can avoid this using OSGi. Unloading parts of an app during runtime (in the shape of jar files called "bundles"), and replacing them with newer versions is one of the fundamental use cases for OSGi. The name of the jar file wouldn't be relevant, so nothing would get overwritten.

If I wanted to do this without resorting to OSGi, I'd check out if Runtime.exec or ProcessBuilder can start subprocesses that continue to run if the parent process is terminated. But OSGi would definitely be my first choice.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The requirement as stated is just what JNLP/Webstart allows!
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point. I was thinking more along the lines of replacing individual bits and pieces of an app (which is how the Firefox update mechanism works), and being able to control that process. If it's acceptable to replace the entire app with whatever the latest version is (sort of like it works for mobile apps), then Webstart makes that quite easy.
 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

I will learn about OSGI.

Javaws/JNLP has its place but I tend to prefer apps that are downloaded once and started locally that way the procedure doesn't change every time Apple looks at Java.

Thanks again.

Joe
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joe Areeda wrote:
Javaws/JNLP has its place but I tend to prefer apps that are downloaded once and started locally that way the procedure doesn't change every time Apple looks at Java.


Your understanding of Webstart is flawed. It is easy to configure Webstart so that an application is started locally with only the modified resources downloaded.
 
Joe Areeda
Ranch Hand
Posts: 334
2
Java Netbeans IDE Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Richard Tookey wrote:
Joe Areeda wrote:
Javaws/JNLP has its place but I tend to prefer apps that are downloaded once and started locally that way the procedure doesn't change every time Apple looks at Java.


Your understanding of Webstart is flawed. It is easy to configure Webstart so that an application is started locally with only the modified resources downloaded.


thanks! I'll dig into that.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!