Results 1 to 5 of 5
  1. #1
    snickers10m is offline Member
    Join Date
    Feb 2012
    Posts
    2
    Rep Power
    0

    Default Adding files to a jar file at runtime

    I've searched google but can't find anything simple and quality.

    Scenario:
    There's a jar file with a bunch of classes in it. You have created new class files, and have edited a few existing ones. You want other people to be able to install these class files into THEIR jar easily, without releasing the entire new jar. So, I need an auto installer that will copy and paste/replace my class files into the jar file.

    Thanks in advance for your responses.

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default Re: Adding files to a jar file at runtime

    Without extracting and re-creating the jar file, I don't think there is another way to do this.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Adding files to a jar file at runtime

    In any case, 'replacing' .class files in a .jar of a running application doesn't make the new version of the class available to the application. At least, not without some very fancy class loading mechanism.

    Also note that not every OS will allow you to delete and replace the .jar while an application is running.

    For automatic updates when launching the application, look into using JNLP / Web Start.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default Re: Adding files to a jar file at runtime

    Normally, version upgrade is kind of packages replacement. Not a *.class file. However, you have to take care about the associations that your application has with the OS.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,433
    Blog Entries
    7
    Rep Power
    20

    Default Re: Adding files to a jar file at runtime

    Google for 'jrebel' it's a clas loader that allows live swapping of loaded classes. I think there's a free trial version.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 8
    Last Post: 09-23-2010, 03:27 PM
  2. Adding jars at runtime
    By tbar0711 in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 02-17-2010, 07:25 PM
  3. Problem in adding new JTextPane at Runtime
    By png in forum AWT / Swing
    Replies: 13
    Last Post: 12-14-2009, 12:14 PM
  4. Adding component at runtime
    By Beju in forum Java Applets
    Replies: 5
    Last Post: 06-16-2009, 11:28 AM
  5. Adding JARs to the classpath at runtime?
    By johann_p in forum Advanced Java
    Replies: 1
    Last Post: 06-26-2007, 10:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •