tags:

views:

14

answers:

3

hi, i have a string say Path ="C:\AAA\bin" which is a path to a project's bin folder. I used new URL(Path) during invocation of addURL method of URLClassLoader class.

ex- addURL(sysLoader,new URL(Path)) ;

its giving unknown protocol:c exception

whats the problem?Help

A: 

Replace new URL(Path) with new File(Path).toURL() and it will work.

Also, don't forget to escape the \ in the file path:

"C:\\AAA\\bin"
Bruno Rothgiesser
+1  A: 

you have to use something like this

Path="file://C://AAA/bin". 

Here 'file' refers to the protocol.

navr
+1  A: 

You first have to tranform your String path into an URL. The simplest way is to create a File from your String path, then call its toURI method.

in other words :

addURL(sysLoader, new File(Path).toURI().toURL());
Riduidel