Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > URLClassLoader

Reply
Thread Tools

URLClassLoader

 
 
ballpointpenthief
Guest
Posts: n/a
 
      12-19-2006
I need to understand ClassLoader s for something, so I am starting with
URLClassLoader to get started. I've fallen down before the first hurdle
unfortunately.
It might be a problem with the URL. I've not touched these before.

If someone could find the problem in this code that would be great.
Matt

import java.net.URLClassLoader;
import java.net.URL;
import java.net.MalformedURLException;

public class Test {

public static void main(String argv[]) {

URL[] urls = new URL[1];
try {
urls[0] = new URL("file:\\");

} catch (MalformedURLException ex) {
System.err.println(ex.getMessage());
}
URLClassLoader c = new URLClassLoader(urls);
try {
c.loadClass("House"); // There exists a House.class file in
the working directory
} catch (ClassNotFoundException ex) {
System.err.println(ex.getMessage()); // I get to here, but
I don't want to!
}
}
}

 
Reply With Quote
 
 
 
 
Thomas Hawtin
Guest
Posts: n/a
 
      12-19-2006
ballpointpenthief wrote:
> urls[0] = new URL("file:\\");


> } catch (ClassNotFoundException ex) {
> System.err.println(ex.getMessage()); // I get to here, but
> I don't want to!


"file:\\" is not a correctly formed file URL. When I change it to
"file:///", it works for me.

Tom Hawtin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
URLClassloader loading class with unknown package name Cory Java 13 05-31-2011 08:31 PM
URLClassLoader and Tomcat Romain Java 2 09-29-2005 10:08 AM
URLClassLoader slow in 1.4.2 Timothy Fosdike Java 0 08-26-2004 02:08 AM
help.! Java URLClassloader Sundar Java 1 11-04-2003 04:02 PM
URLClassLoader plugin system.... getting java.lang.NoClassDefFoundError netpro2k Java 2 08-21-2003 03:12 PM



Advertisments