Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Trouble creating an update button

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have just tried to create an automatic update button for an application of mine. First my app checks if a newer version is available, if so it then it is supposed to start an updating app which downloads the latest version of the program (which is an executable Jar). The updater then replaces the old version with the new one and starts the new version running. In order to replace the old file with the new one I need to shut down the old version.

I have tried using System.exit(0); but this seems to shut down my updater as well

Could someone please let me know where I am going wrong here? How can I shut down the original app without shutting down the updater?

 
Marshal
Posts: 26914
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should run your updater as a separate process.
 
Colin McTaggart
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I do that? I am a bit inexperienced as a programmer atm. Right now I run my updater using this code:

 
Paul Clapham
Marshal
Posts: 26914
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, that's how you should do it. But you say that shutting down the application which does that also causes that Process to be terminated?
 
Colin McTaggart
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I just realized that I may not be passing in arguments properly to the updater... My code actually looks like this:



I'm going to test to see if this is the case.


 
Colin McTaggart
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried replacing my update app with another that does not use arguments and it was shut down as well. Does System.exit(0); shut down every process running in the JVM? If so is there any was to shutdown a specific app in the JVM?
 
Colin McTaggart
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I realized that my arguments had to be separated with commas and in their own sets of quotation marks so it works fine now. Thanks for the help
 
Paul Clapham
Marshal
Posts: 26914
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Glad it's fixed.

(So the answer was, it wasn't anything to do with the main application shutting down, it was just that the process you started always failed until you got that fixed?)

(And as you may have figured out by now, the phrase "process running in the JVM" doesn't mean anything. The process you create is an independent process which isn't "in the JVM" in any way. Just trying to clarify for the benefit of future readers.)
 
Colin McTaggart
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like I misunderstood how JVM works, I'll read up on that tomorrow. Thanks for pointing that out
 
reply
    Bookmark Topic Watch Topic
  • New Topic