Access images inside jar

前端 未结 1 1809
北恋
北恋 2021-01-23 01:50

First. I know that there already exists a variety of topics on how to access the image inside the jar file. Second. I tried many options and none of them did not work. Of cours

相关标签:
1条回答
  • 2021-01-23 02:07
    1. Don't use the File.separator in getResource() - it always takes / (think of it as an URL HREF).
    2. Prefix the path with / to ensure the class loader searches from the root of the class-path, rather than relative to the package of the class.
    3. Check that good.PNG is the correct case. It does not matter on the Windows file-system, but getResource() is case-sensitive.
    0 讨论(0)
提交回复
热议问题