简体   繁体   中英

Java Relative URL for URL class

I have a file in my working project. It's in the current directory of source code.

Main
   -> src
       [packeges]
   -> plugin
        ->MyLib.jar
   -> other

I have a class in a packege of the src folder. Now I want to load the jar file to URL class like,

new URL("jar:file:/./plugin/MyLib.jar!/") // this relative file path is wrong

Could you please tell me what is the corrent relative path here?

I think that "." refers to the current directory of your binaries (*.class), not of your source code. Try create a url relative to your binaries.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM