---
title: "How should we set classpath URL's to URLClassLoader?"  
description: "How should we set classpath URL's to URLClassLoader?"  
author: "Anonymous User"  
published: 2015-12-03  
updated: 2015-12-03  
canonical: https://www.mindstick.com/forum/33676/how-should-we-set-classpath-url-s-to-urlclassloader  
category: "java"  
tags: ["java"]  
reading_time: 1 minute  

---

# How should we set classpath URL's to URLClassLoader?

I have this piece of [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):\

```
URLClassLoader tmp = new URLClassLoader(new URL[] { getClassPath() });private static URL getClassPath() {    return new URL("/home/rudik/workspace/cl/target/classes/");}
```

I got /[home](https://www.mindstick.com/articles/126322/how-to-keep-your-home-safe-while-traveling)/rudik/[workspace](https://www.mindstick.com/blog/304118/transform-your-workspace-tips-for-enhancing-focus-and-productivity)/cl/[target](https://yourviews.mindstick.com/view/81207/small-industries-should-be-the-target-of-economic-relief-package)/classes/ from Arrays.toString(((URLClassLoader) MyClass.class.getClassLoader()).getURLs()) execution.\
When I [execute](https://www.mindstick.com/interview/49/how-can-i-execute-a-php-script-using-command-line) it I get this [exception](https://www.mindstick.com/articles/1824/objective-c-exception-handling):\

```
java.net.MalformedURLException: no protocol: /home/rudik/workspace/cl/target/classes/
```

## Replies

### Reply by Anonymous User

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/");}
```


---

Original Source: https://www.mindstick.com/forum/33676/how-should-we-set-classpath-url-s-to-urlclassloader

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
