"Smart update" question or how to overwrite the library in current use

Hello,
I would like to add a "smartUpdate" feature to an application i.e.
1. Read an updated library from the web (e.g. as archive- zip)
2. Extract files from archive and write them to a local drive.
3. After all the files are written, close the appliaction and restart it.
#1 is easy enough, there problems is with #2 and #3.
I will need to overwrite jar file that the running application is using.
Does anybody has experience with this. Any ideas how to do this.
Thank you.
Leo

Appreciate any other ideas...If you have to exchange classes in an application while it is still running, this will always be a bit tricky (if not
impossible). It is much easiser to close and restart the application (= make the OS call the Java-interpreter again). But if you decide, that restarting from the OS is not possible, there is some work to do :-)
There are three main problems:
1. If your classes are loaded from Jar-files, the Jar-files will be locked by the java-process. Once a class has been loaded from a Jar-file, that file is write-protected
2. Java will not reload a class that it has already loaded, even if the Class- or Jar-File has changed
3. Even if the class would be reloaded, this could not affect any instances of these classes.
Problems 1 and 2 can be solved by using a custom ClassLoader (this is still 100% pure Java, no hack or
something).
This custom ClassLoader could be written in a way that it could close the Jar-Files on demand (closing the Jar-File every time a class has been loaded would slow down class loading significantly).
To force reloading (=using the new jar-file) you would have to instantiate a new ClassLoader (= another instance of your own custom ClassLoader). This new ClassLoader will use the new versions.
The third problem is just a matter of your application; you must ensure that it re-instantiates everything with the new ClassLoader.
So, it would be something like:
//Create custom CLassLoader
MyClassLoader cl = new MyClassLoader();
//--- start update code (assuming my.package.MyClass1.main will receive the new jar-file)
Class mc = cl.loadClass( "my.package.MyClass1");
Method main = mc.getMethod( "main", new Class[]{ String[].class } );
main.invoke( null, new Object[]{ new String[0] } );
//--- overcome write-protection
cl.closeFiles();
//--- now copy the new Jar-File into the appropriate directory
//--- dispose first ClassLoader and create a new one
cl = new MyClassLoader();
//--- start app (assuming my.package.MyClass2.main is the "real" application)
Class mc = cl.loadClass( "my.package.MyClass1");
Method main = mc.getMethod( "main", new Class[]{ String[].class } );
main.invoke( null, new Object[]{ new String[0] } );All this ClassLoader stuff is a bit tricky, but this kind of "smart update", where you exchange classes while the VM is still running, is not a trivial problem (though
it's quite common if you're write application servers).
HTH
Matthias

Similar Messages

  • How can I find out where the Library files currently used by iTunes are located?

    I have had a bit of a nightmare sorting out my iTunes files so I have various versions of Library files all over the place. How can I tell where the Library file that iTunes is currently using is located? In Preferences I can see the Library "Name", but I don't think that is much help. Preferences also shows where my i-Tunes media folder is but not where the Library files are.
    Any help greatly appreciated.
    J

    Ah, I was assuming you would search in Finder and display some details. All alternative approach is to Option start iTunes and click the Choose option. It should show a file selection box targeted at the folder of the currently active library.
    tt2

  • On a new imac how much of the HDD is already used with the OS,iLife,apps..

    Looking to buy my 1st ever iMac, the one Im going to get is the base one, with 250Gb HDD (I may upgrade to 320Gb for UK £29 though)
    My question is how much of the HDD is already used by OS X and everything on it? I understand there is some free trial stuff onthat can be installed eg MS Office, iWork etc I would want these removed as wouldnt want them so how much is left before you start adding your own stuff
    I also want to install Win XP on it so need to know what to do, 250Gb in todays computing is very stingy I think, so I need an idea
    cheers

    Here's are some disk usage information from my 20" white C2D. The numbers
    are running totals that include periodic software updates and some of my own
    stuff -- but that would be less than 0.5 GB of the final total.
    OS-X with "no optional packages" is a very usable system; it includes 'core'
    applications such as Safari, iTunes, Quicktime. It does not include any of the
    iLife apps or the iWork/MS_Office test-drive bloatwares.
    The large increase in disk usage for a minimum Leopard system is partly due
    to the inclusion of more apps in the 'core' OS package. Some things that were
    optional in Tiger have become part of the "minimum" Leopard install.
    The Xcode software development tools are a standard part of every OS-X
    distribution, but since most customers have no use for them, they're not
    included in the factory-installed disk image. If you don't plan to install
    them, subtract 3.4 GB from the final tally.
    Factory pre-installed Tiger 10.4.8 & bundled software .................. 16.4 GB
    Erase & Install Tiger 10.4.8 with NO optional packages .................. 2.9 GB
    SoftwareUpdate to 10.4.10, with NO optional packages .................. 3.1 GB
    Erase & Install Leopard 10.5.0 with NO optional packages ............... 6.6 GB
    SoftwareUpdate (11/11, immediately after Leopard install) ............. 6.7 GB
    Install Xcode SW development tools from Leopard DVD ................. 10.1 GB
    Install & SoftwareUpdate iLife'08 (except iWeb & GarageBand) ....... 12.3 GB
    SoftwareUpdate to Leopard 10.5.1.................................................. 12.5 GB
    IMO, 250 GB is FAR more than you'll ever need for installable software plus
    a sizeable collection of music/photos. OTOH, no amount of disk space will
    ever be enough for an avid music/photo/video junkie, and everyone should
    have an external backup drive. So, stick with the standard internal drive and
    buy more external storage.
    ...a billion here, a billion there -- and pretty soon you're talkin' 'bout alot of money,
    Looby

  • [svn:fx-trunk] 10545: Make DataGrid smarter about when and how to calculate the modulefactory for its renderers when using embedded fonts

    Revision: 10545
    Author:   [email protected]
    Date:     2009-09-23 13:33:21 -0700 (Wed, 23 Sep 2009)
    Log Message:
    Make DataGrid smarter about when and how to calculate the modulefactory for its renderers when using embedded fonts
    QE Notes: 2 Mustella tests fail:
    components/DataGrid/DataGrid_HaloSkin/Properties/datagrid_properties_columns_halo datagrid_properties_columns_increase0to1_halo
    components/DataGrid/DataGrid_SparkSkin/Properties/datagrid_properties_columns datagrid_properties_columns_increase0to1
    These fixes get us to measure the embedded fonts correctly when going from 0 columns to a set of columns so rowHeight will be different (and better) in those scenarios
    Doc Notes: None
    Bugs: SDK-15241
    Reviewer: Darrell
    API Change: No
    Is noteworthy for integration: No
    tests: checkintests mustella/browser/DataGrid
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-15241
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/DataGrid.as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/dataGridClasses/DataGridBase .as
        flex/sdk/trunk/frameworks/projects/framework/src/mx/controls/dataGridClasses/DataGridColu mn.as

    Hi Matthias,
    Sorry, if this reply seems like a products plug (which it is), but this is really how we solve this software engineering challenge at JKI...
    At JKI, we create VI Packages (which are basically installers for LabVIEW instrument drivers and toolkits) of our reusable code (using the package building capabilities of VIPM Professional).  We keep a VI Package Configuration file (that includes a copy of the actual packages) in each of our project folders (and check it into source code control just as we do for all our project files).  We also use VIPM Enterprise to distribute new VI Packages over the network.
    Also, as others have mentioned, we use the JKI TortoiseSVN Tool to make it easy to use TortoiseSVN directly from LabVIEW.
    Please feel free to contact JKI if you have any specific questions about these products.
    Thanks,
    -Jim 

  • No question, I just wanna say thanks to the person who discovered how to change the correct dns to use FaceTime. The 8.8.8.8. Really work. Genius. Thanks again.

    No question, I just wanna say thanks to the person who discovered how to change the correct dns to use FaceTime. The 8.8.8.8. Really work. Genius. Thanks again.

    solved

  • Hi there, i'm trying to change a PDF document written in arabic to Word document, the problem is (( i can't find the arabic language in adobe )) the question is how to install the arabic language

    hi there, i'm trying to change a PDF document written in arabic to Word document, the problem is (( i can't find the arabic language in adobe )) the question is how to install the arabic language

    <moved from Downloading, Installing, Setting Up to Creating, Editing & Exporting PDFs>

  • WRT54G Question on how far does the signal reach?

    Question on how far does the signal reach?
    Like from the system box at home base, could you take the laptop what distance from it? Miles? Or jus a short distance? And what distance if anyone knows?
    Message Edited by White_Devil on 04-09-2008 08:21 PM
    [b]Loved Charlton Heston[/b]

    My 54G is at the far end of my house in my home office, 80+ feet away thru 4 walls I still get 25% signal, enough for a decent connection. Having an all wood construction house helps a bit. Once I was in my car out in the driveway (~90 ft) and it still worked OK.
    I've got the bigger hi-gain antennas, not sure that they improve the range that much. I didn't really notice much signal gain going from the short ones to the tall ones.

  • I was recently prompted to update iPhoto and make changes to the library.  I did it but it keeps hanging up in step 5 or 6 and won't complete the cycle.  I have used force quit, rebooted and started again several times.  How do i get this to work?

    I was recently prompted to update iPhoto and make changes to the library.  I did it but it keeps hanging up in step 5 or 6 and won't complete the cycle.  I have used force quit, rebooted and started again several times.  How do i get this to work?

    Back Up and try rebuild the library: hold down the command and option (or alt) keys while launching iPhoto. Use the resulting dialogue to rebuild.
    If that fails:
    Restore from your back up, repair the Library and try again.

  • I am trying to update my iphone 3GS software but itunes just says that this is the current version of itunes, it does not see the phone update - anyone know how to get the phone updated?

    I am trying to update my iphone 3GS software but itunes just says that this is the current version of itunes, it does not see the phone update - anyone know how to get the phone updated?

    Mike
    I have done that and it is through pressing that update, which tells me that there is anew version of iphone software, that the prompt comes telling me that this is the current itunes?

  • How to overwrite the xml file...

    Hi,
    can any one help me how to overwrite the xml file.....
    ~~Sk

    Flash Player cannot write XML files at all. but using
    php+flash we could do it .

  • How to overwrite the system event "Close"?

    Hi,
    How to overwrite the event for "Close" button in a screen?
    "Close" is the system event. I need to write my own code for "Save" in the event and then close the screen.
    Pls help me in doing this. Provide me the sample code.
    Regards,
    SAP Lover

    Hi,
    Check out this related thread ... Hope it helps
    Re: how to close  screen?
    Regards,
    Santosh

  • Quick question: How to get the scrolled page number using af:table

    Hi,
    When using range paging on scrolled table, how to get the current scrolled page number(1,2,3...), for example when moving the table vertical scroll bar forward or backward, is there any method in ViewObjectImpl class that I can use to get such information? I have seen the method scrollToRangePage(int i), but when scrolled ("Fetching data..."), it doesn't not get into this method. So it is wrong usage for this method, right?
    Thanks

    Didn't you just ask that question in this thread?: How to catch the page number when using scroll table in ADF 11g?
    A bit of patience might be in order.
    CM.

  • How to make the library visible IN AN EXTERNAL disk?

    Hello.
    Searched this forum (found about 25 identical questions and answers "how to make the library visible").
    I turned mine and it is constantly visible now.
    Before installing Lion made a bootable image.
    When I connect the external HD, I see it in the Finder side bar, click on users>myname and the library folder doesn't show up.
    Tried the 3 ways to make it visible but they all bring back and show the Lion's library on my MBP, not the one in the external HD.
    Any ideas?
    (BTW, I am just an "amateur user", not too heavy, so just, please take in consideration that if you explain to me slowly I will understand quicly)...
    Thanks in advance.
    Saul

    Thank you Baltwo.
    Don't I know you from CCC? (If judging from your answer I do, always hit the nail in the head)...
    Yes, I guess I used the wrong terminology. Anyway, I did a bootable disk/image/clone, however it's called, with CCC (Carbon Copy Cloner), which BTW I am using for at least 3 years and saved several times my behind.
    So, if I understood you right, you mean booting from my external HD and make the library visible (I don't remember if the clone was made after installing Lion or still while in Snow L, but will check).
    I'll try and update here if it worked.
    Thanks again and have a good evening.
    Saul

  • How to automate the data load process using data load file & task Scheduler

    Hi,
    I am doing Automated Process to load the data in Hyperion Planning application with the help of data_Load.bat file & Task Scheduler.
    I have created Data_Load.bat file but rest of the process i am unable complete.
    So could you help me , how to automate the data load process using Data_load.bat file & task Scheduler or what are the rest of the file is require to achieve this.
    Thanks

    To follow up on your question are you using the maxl scripts for the dataload?
    If so I have seen and issue within the batch (ex: load_data.bat) that if you do not have the full maxl script path with a batch when running it through event task scheduler the task will work but the log and/ or error file will not be created. Meaning the batch claims it ran from the task scheduler although it didn't do what you needed it to.
    If you are using maxl use this as the batch
    "essmsh C:\data\DataLoad.mxl" Or you can also use the full path for the maxl either way works. The only reason I would think that the maxl may then not work is if you do not have the batch updated to call on all the maxl PATH changes or if you need to update your environment variables to correct the essmsh command to work in a command prompt.

  • IPhoto won't open due to the not being updated but when I check to upgrade to iPhoto 11 it tells me it is installed. The photos in the library were modified using 9.1.5 and the iPhoto is said to be 7.1.5 (iPhoto 8). Any ideas?

    iPhoto won't open due to the not being updated but when I check to upgrade to iPhoto 11 it tells me it is installed. The photos in the library were modified using 9.1.5 and the iPhoto is said to be 7.1.5 (iPhoto 8). Any ideas?

    How do you know the library was modified with iPhoto 9 (11)?  If you've never had iPhoto 9 on your Mac it could'nt have.  It sounds like a damaged library. Make a temporary, backup copy (if you don't already have a backup copy) of the library and apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Select the options identified in the screenshot. 
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    Download iPhoto Library Manager and launch.
    Click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option
    In the next  window name the new library and select the location you want it to be placed.
    Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

Maybe you are looking for

  • How do I get  CR-XI R2 to install?

    What a nightmare!  I was advised to update my CR-IX R1 (in the hopes that this would help with a failed Active-X call).  I eventually determined that I could go from R1 to R2 by downloading a file 14-00806-085.zip, and running this.  I removed R1 (us

  • Ipod corrupted and wont be recognized in itunes

    My itunes library didn't work for about 3 weeks and when it finally did, my ipod wouldn't connect to my computer. I tried using 4 different usb wires and none of them worked. It would say do not disconnect on my ipod for a minute and then go to the m

  • Alternate methods of Payment other than credit cards?

    To whom this may concern, I was on the iTunes store recently, and I came across the "free" download single of the week. Well I clicked the link, and it said you need to login. So I logged in, and it said that I needed to review my account information

  • How to make VPN client auto timeout when it still idle?

    How to make VPN client auto disconnect when it still idle? Hi,I found some user still connected the VPN evenif they dose not use the VPN resouse. I try to set a "idle timeout" for the VPN configuration. We use PIX515 8.0.3 and CISCO ACS 4.2 for the V

  • Where to put ringtones in the N9?

    I dont really know where to put this thread. So mods feel free to move it. I didnt really care for any of the stock ring tones on the N9, and I had a ring tone on my N97 that was the sound played on Star Trek TNG when the shuttle bay doors would star