Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法从src/images文件夹访问图像_Image - Fatal编程技术网

无法从src/images文件夹访问图像

无法从src/images文件夹访问图像,image,Image,我已经在Netbeans中的src下创建了images文件夹。在我的应用程序中使用以下代码获取图像 URL URL=ClassLoader.getSystemClassLoader().getResource(“/images/file.jpg”) logoimg=新图像图标(url) 但它并没有加载任何图像。我已经尝试了许多现有的解决方案,但没有用 我的要求是需要在任何系统中运行我的应用程序jar,而不丢失映像 以下代码修复了我的问题 ImageIcon ImageIcon=新的ImageIc

我已经在Netbeans中的src下创建了images文件夹。在我的应用程序中使用以下代码获取图像

URL URL=ClassLoader.getSystemClassLoader().getResource(“/images/file.jpg”)

logoimg=新图像图标(url)

但它并没有加载任何图像。我已经尝试了许多现有的解决方案,但没有用


我的要求是需要在任何系统中运行我的应用程序jar,而不丢失映像

以下代码修复了我的问题

ImageIcon ImageIcon=新的ImageIcon(getClass().getResource(“/images/logo.png”)

可能重复的