|
-
October 24th, 2011, 04:34 PM
#1
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
-
October 25th, 2011, 03:34 PM
#2
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
-
October 27th, 2011, 04:22 AM
#3
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 Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|