开发者

URL load error during adding

开发者 https://www.devze.com 2022-12-23 18:29 出处:网络
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.

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"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号