Java Images not drawn when running java -jar

后端 未结 2 421
暖寄归人
暖寄归人 2020-12-12 07:22

I have a problem i have never had before and couldnt find a solution on the web. I have a small Programm which uses some images to print a menu.

This is the Class i

2条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-12 07:54

    The ".getPath()" part of your code excludes the leading part of the URL.
    This needs to be present if your resource is part of a jar file.

    I suggest you remove the ".getPath()" and use the full URL.
    Printing out the full URL is a good idea too, in a System.out.println for example.

提交回复
热议问题