Forum Stats

  • 3,854,528 Users
  • 2,264,379 Discussions
  • 7,905,718 Comments

Discussions

URLClassLoader in web app- add external jar to the web app classpath

811814
811814 Member Posts: 15
Hi all,

I have a query for u guys, I'm using a jar parser code in my web application. This jar parser method uses URLClassLoader to parse the jar and loads the classes of a jar. After the class is loaded it is checked whether its an instance of other preloaded class B(this class jar is in lib).

For ex: Class classss = cl.loadClass(com.A); // Class A inherits Class B

Object obj = classss.newInstance();

boolean val = ojb instanceOf B

So the value of val should be true, but its false because its missing the jar file(Class B) in the classpath.

So anyone have any idea about how to add external jar to the web application jar.

Ur help is much appreciated.

Thanks in advance,
Bachchu
Tagged:

Answers

  • DrClap
    DrClap Member Posts: 25,479
    I'm not sure what you mean by "the web application jar".

    If you want a jar to be included in your web application, it should be in the /WEB-INF/lib folder of the web application.
  • 811814
    811814 Member Posts: 15
    First, I would like to thank you.

    I have a custom jar file in lib folder of my application but I want the same jar file to be in the classpath.

    For ex: in eclipse IDE if you go to "Run COnfigurations" and classpath u can see bootstrap.jar set as classpath. Similarly I wanna set my custom jar file in the classpath.

    Any idea?

    Thanks again,
    Bachchu
  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    Bachchu wrote:
    First, I would like to thank you.

    I have a custom jar file in lib folder of my application but I want the same jar file to be in the classpath.

    For ex: in eclipse IDE if you go to "Run COnfigurations" and classpath u can see bootstrap.jar set as classpath. Similarly I wanna set my custom jar file in the classpath.

    Any idea?
    You are not making much sense. Do you want to add a library on the classpath of a RUNNING web application?
This discussion has been closed.