This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes How Add new classess to the System Classs loader. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "How Add new classess to the System Classs loader." Watch "How Add new classess to the System Classs loader." New topic
Author

How Add new classess to the System Classs loader.

echarish Kumar
Ranch Hand

Joined: Feb 02, 2010
Posts: 42
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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 43957
    
  33
Welcome to the Ranch

I am afraid your question is too difficult for "beginning Java", soI shall move it.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: How Add new classess to the System Classs loader.
 
It's not a secret anymore!