0

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/

1 Answer 1

2

You don't pass a URL string to the URL constructor. In your case it should be

private static URL getClassPath() {
    return new URL("file:///home/rudik/workspace/cl/target/classes/");
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, Steffen Kreutz!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.