http://stackoverflow.com/questions/3580752/java-dynamically-loading-a-class
On Mar 29, 12:19 pm, Jeff MAURY <[email protected]> wrote: > Yes, > > your code is wrong in the end. You try to load a class from the name of the > JAR file that contains this class which is wrong because there is no strict > relation between a main class and its containing JAR file. > > Jeff > > > > > > On Wed, Mar 21, 2012 at 2:28 PM, [email protected] <[email protected]> wrote: > > Hello, > > i try to load dynamically some Librairies, but i have this Error Message: > > java.lang.ClassNotFoundException: jboss-deployment.jar > > at java.net.URLClassLoader$1.run(URLClassLoader.java:202) > > at java.security.AccessController.doPrivileged(Native Method) > > at java.net.URLClassLoader.findClass(URLClassLoader.java:190) > > at java.lang.ClassLoader.loadClass(ClassLoader.java:306) > > at java.lang.ClassLoader.loadClass(ClassLoader.java:247) > > at > > org.nabucco.testautomation.jenkins.plugin.ClassLoading.setClasspath(ClassLoading.java:64) > > > here is how i do it : > > > try { > > jarUrl = files[i].toURL(); > > > System.out.println(files[i].getName() + " was created." + > > jarUrl); > > } catch (MalformedURLException e1) { > > System.out.println("Jar-URl was not created."); > > e1.printStackTrace(); > > } > > URL[] filesUrls = new URL[] { jarUrl }; > > URLClassLoader ucl = new URLClassLoader(filesUrls); > > Class c = ucl.loadClass(files[i].getName()); > > can somebody help me? > > thanks, > > Gil > > -- > Jeff MAURY > > "Legacy code" often differs from its suggested alternative by actually > working and scaling. > - Bjarne Stroustrup > > http://www.jeffmaury.comhttp://riadiscuss.jeffmaury.comhttp://www.twitter.com/jeffmaury- > Hide quoted text - > > - Show quoted text -
