Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3274700
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:04:01+00:00 2026-05-17T19:04:01+00:00

I would like to implement a java application (server application) that can download a

  • 0

I would like to implement a java application (server application) that can download a new version (.jar file) from a given url, and then update itself at runtime.

What is the best way to do this and is it possible?

I guess that the application can download a new .jar file and start it. But how should I do the handover, e.g. know when the new application is started and then exit. Or is there a better way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:04:01+00:00Added an answer on May 17, 2026 at 7:04 pm

    The basic structure of a solution is as follows:

    • There is a main loop responsible for repeatedly loading the latest version of the app (if required) and launching it.

    • The application does its thing, but periodically checks the download URL. If it detects a new version it exits back to the launcher.

    There are a number of ways you could implement this. For example:

    • The launcher could be a wrapper script or binary application that starts a new JVM to run the application from a JAR file that gets replaced.

    • The launcher could be a Java application that creates a classloader for the new JAR, loads an entrypoint class and calls some method on it. If you do it this way, you have to watch for classloader storage leaks, but that’s not difficult. (You just need to make sure that no objects with classes loaded from the JAR are reachable after you relaunch.)

    The advantages of the external wrapper approach are:

    • you only need one JAR,
    • you can replace the entire Java app,
    • any secondary threads created by the app, etc will go away without special shutdown logic, and
    • you can also deal with recovery from application crashes, etc.

    The second approach requires two JARs, but has the following advantages:

    • the solution is pure Java and portable,
    • the changeover will be quicker, and
    • you can more easily retain state across the restart (modulo leakage issues).

    The “best” way depends on your specific requirements.

    It should also be noted that:

    • There are security risks with auto-updating. In general, if the server that provides the updates is compromised, or if the mechanisms for providing the updates are susceptible to attack, then auto-updating can lead to a compromise of the client(s).

    • Pushing a update to a client that cause damage to the client could have legal risks, and risks to your business’ reputation.


    If you can find a way to avoid reinventing the wheel, that would be good. See the other answers for suggestions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.