CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2003
    Posts
    402

    dynamically load .jar file in a java application

    I am kind of new to java, but have dynamically linked in DLL's in windows applications as well as static libraries in C/C++. In java is it possible to dynamically link a .jar file into another java application.

    In other words I have a class structure defined in a .jar file and I want to create instances of the class defined in the .jar file in my java application. However, the catch is I want to do this at runtime. I do not want to recompile the source code every time the class structure in the .jar file changes.

    Thanks

  2. #2
    Join Date
    Oct 2011
    Posts
    9

    Re: dynamically load .jar file in a java application

    Hi,

    I did a quick search on google and found this link about dynamically loading classes.. i hope it helps some:
    http://tutorials.jenkov.com/java-ref...reloading.html

  3. #3
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: dynamically load .jar file in a java application

    The link provided by leon945 is a quite advanced solution that is only required if you want to change the code and inject the new changes without shutting down the application.

    If you have classes in a jar, as long as the jar file is on the classpath, any other code on the classpath (in another jar or otherwise) can access them.

    It is quite common for large applications to consist of tens of jar files many of which may be free libraries such as Log4J, JodaTime etc each of which ships in it's own jar. All you have to do is add the jar to the classpath and you can use the library.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured