Adding library or classpath at runtime

Source: Internet
Author: User

Having some trouble adding a library path at runtime using the system. setproperty (Java. Library. Path) or system. setproperty (Java. Class. Path) or system. loadlibrary ()?

I have created a app which loads in classes via the classloader at runtime to run, but discovered some of these classes requires. jar files as well (extra library classes ). is there any way to just set. JAR file as a library at runtime ??? This cannot be done through adding it to the classpath at design time as I do not know the name of the class or. jar file until runtime.

You cocould write a custom class loader or use urlclassloader. See:
1) http://www.exampledepot.com/egs/java.lang/LoadClass.html
2) API documentation of the Java. Lang. classloader class.
3) http://www.javaworld.com/javaworld/jw-03-2000/jw-03-classload.html
4) http://forum.java.sun.com/thread.jspa? Threadid = 300557 & START = 0 & tstart = 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.