我在jbuilder编译器下编译运行都能够成功,但是直接双击生成的jar文件就不能成功。我做的是一个swing系统,起始页的按钮有图片。图片放在images文件夹下,看了一下jar也确实有images文件夹里面也有图片。但就是不能正常运行了,怀疑还是没能读到图片。难道jar下获取的不是java类的加载路径么。
 
所用的方法是
 
try{
            InputStream input = Thread.currentThread().getContextClassLoader().getResourceAsStream("order.jpg");   
            byte[] imageByte = new byte[input.available()];
            input.read(imageByte);
            ImageIcon imageIcon1 = new ImageIcon(imageByte);
  
            }catch(IOException e){
   &n bsp;            e.printStackTrace();
            }