Results 1 to 9 of 9
  1. #1
    mnsse is offline Member
    Join Date
    Mar 2008
    Posts
    6
    Rep Power
    0

    Default Different versions of Jar

    Hi,

    I have a webapplication that uses Saxon8.jar but now I have to add some new functionality to the webapplication and for that Saxon9.jar is ideal. Without affecting or breaking previously written code, how can I dynamically load/unload JAR (saxon9.jar specifically)?

    For example:
    Whenever the new functionality in the webapplication is invoked, Saxon9.jar is loaded, completes the job, and then unloads.

    I have tried URLCLassLoader but that doesn't seem to work for me or maybe I do not know how to use it to get Factory classes and then objects from the factory.

    If anyone can help that would be really helpful.

    Thank you.

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Do you mean that you want to use both jars? Why not just replace the old jar with the new version?

  3. #3
    mnsse is offline Member
    Join Date
    Mar 2008
    Posts
    6
    Rep Power
    0

    Default

    New version of the library is not backward compatible and that is the problem

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Trying to use both versions at the same time will give you problems if not impossible.
    Better choose the one where you have less work to do to adapt your code and use that one.

  5. #5
    mnsse is offline Member
    Join Date
    Mar 2008
    Posts
    6
    Rep Power
    0

    Default

    Having only one version doesn't seem to be an option.
    Any thing that could be done?

  6. #6
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    you cannot load both at the same time (unless you change the package path)

    but you can dynamically load a class from a specified jar path. In other words use the URLClassLoader to load a class stored in a jar:

    Java Code:
    filePath = "jar:file://" + jarPath + "!/";
    Last edited by mrmatt1111; 09-14-2009 at 07:36 PM.
    My Hobby Project: LegacyClone

  7. #7
    mnsse is offline Member
    Join Date
    Mar 2008
    Posts
    6
    Rep Power
    0

    Default

    Thanks mrmatt1111.
    URLClassLoader is what I have been playing with but simple classes are ok, you get an instance of the class and you are good to go. How about something like:

    TFactory tf = TFactory.newFactory();
    TClass tcl = tf.getNewTClass( abc, xyz);

    I don't think this is possible with URLCLassLoader, it doesn't even compile.

  8. #8
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    What if those those classes you are trying to load depend on new classes as well?

  9. #9
    mnsse is offline Member
    Join Date
    Mar 2008
    Posts
    6
    Rep Power
    0

    Default

    I think that is what my question is.
    How to use URLClassLoader when the new classes depend on each other.

Similar Threads

  1. Java Versions
    By hiranya in forum New To Java
    Replies: 6
    Last Post: 10-27-2009, 12:42 PM
  2. JDK versions on web server and client machines
    By sunjavaboy in forum New To Java
    Replies: 1
    Last Post: 03-21-2008, 04:59 AM
  3. Can I delete/uninstall older versions of Java?
    By LudwigKarl in forum New To Java
    Replies: 3
    Last Post: 03-19-2008, 10:23 AM
  4. Using different versions of Java
    By javaplus in forum New To Java
    Replies: 2
    Last Post: 01-04-2008, 08:28 PM
  5. Concurrent Versions System (CVS)
    By JavaForums in forum Eclipse
    Replies: 0
    Last Post: 05-02-2007, 03:03 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
  •