Skip to main content

Using of reflection:strange beheviour

1 reply [Last post]
Joined: 2005-08-31

I'm trying to dinamical load classes that have dependecies from some jar file. I have writed this example.

public class prova {

public prova()throws Exception{

URLClassLoader cl;
File f1=new File("C:/IRApplication/lib/jdeal/jdeal.jar");
File f2=new File("C:/IRApplication/IR");
File f10=new File("C:/IRApplication/extensions/algorithms/DCGA");

URL url1=f1.toURL();
URL url2=f2.toURL();
URL url10=f10.toURL();

URL[] u=new URL[] {url2,url1,url10};
cl = new URLClassLoader(u,this.getClass().getClassLoader());

Class c=Class.forName("it.unisannio.rcost.cise.dcga.IRDeterministicCrowding",true,cl);
* @param args
public static void main(String[] args) throws Exception{
prova p=new prova();



An exception is throwed.

Exception in thread "main" java.lang.NoClassDefFoundError: pt/laseeb/jdeal/ChromosomeEvaluator
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at Source)
at Source)
at$100(Unknown Source)
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at prova.(
at prova.main(

Could someone help me to understand why?? There are lots of days that I try to understand!!!

Message was edited by: giuseppe83

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-08-31