Java: When a program is .jar 'ed, it no longer reads the images in the jar file? -
 I need to run the computer without exporting the files. 
 For the time being, there are images to store my code: 
  image icon icon = new image ("images \\ images2.gif");    This is not just an image because I am adding it to jlabal. 
 When I issue the entire program, it stores the image file in the jar. 
 When I go to run the real problem, then there is no image. 
Again, I can not just leave .jar in a folder with images already it has to work on a different computer by itself. System class loader:
You want to get through the picture system class loader:
 < Code> URL url = ClassLoader.getSystemClassLoader (). GetResource ("Pictures / images2.gif"); Icon icon = new image icon (url)     image  is in the root of the square. 
 Note that the Java runtime will translate into OS specific divider ( / ) ( \  for Windows). 
Comments
Post a Comment