Forums Register Login

How Add new classess to the System Classs loader.

+Pie Number of slices to send: Send
I want to develope a jsp page which should take a JAR file as an input and then add all the classess in that jar to to the System Class Loader. it should be such that once loaded these classess should be availabele to the whole system wihout needing to load the classess from the jar.

I have created a URLClassLoader

public static URLClassLoader getURLClassLoader(URL jarURL) {
return new URLClassLoader(new URL[] { jarURL }, ExternalJarUtils.class.getClassLoader());}
=========================================================
and here i am loadining the class.
------------------------------------
urlLoader = ExternalJarUtils.getURLClassLoader(new URL("file",url, jarName));
aClass = Class.forName(jobClass, true, urlLoader);
========================================

The PROBLEM IS EVERY TIME I NEED THIS CLASS I HAVE TO READ THE JAR. which is not possible in my sitiution.

I will really appriciate any help regarding this.
+Pie Number of slices to send: Send
Welcome to the Ranch

I am afraid your question is too difficult for "beginning Java", soI shall move it.
That's a very big dog. I think I want to go home now and hug this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 915 times.
Similar Threads
loading JDBC driver from a Jar (not in classpath)
Stumped on classloading problem! Help!
dynamically loading a class file from a jar file
Thoroughly Confused about ClassLoading in JAVA
ClassNotFoundException when deserialized from tomcat web app
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 02:41:38.