B
ballpointpenthief
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!
}
}
}
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!
}
}
}