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 addUR开发者_如何转开发L method of URLClassLoader class.
ex- addURL(sysLoader,new URL(Path)) ;
its giving unknown protocol:c exception
whats the problem?Help
you have to use something like this
Path="file://C://AAA/bin".
Here 'file' refers to the protocol.
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());
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"
精彩评论