forum

Home / DeveloperSection / Forums / How should we set classpath URL's to URLClassLoader?

How should we set classpath URL's to URLClassLoader?

Anonymous User 1168 03-Dec-2015
I have this piece of code:

URLClassLoader tmp = new URLClassLoader(new URL[] { getClassPath() });
private static URL getClassPath() {
    return new URL("/home/rudik/workspace/cl/target/classes/");
}
I got /home/rudik/workspace/cl/target/classes/ from Arrays.toString(((URLClassLoader) MyClass.class.getClassLoader()).getURLs()) execution.

When I execute it I get this exception:

java.net.MalformedURLException: no protocol: /home/rudik/workspace/cl/target/classes/

Updated on 03-Dec-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By