Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   use non java files in jar (http://www.programmingforums.org/showthread.php?t=13322)

mrynit Jun 11th, 2007 12:34 AM

use non java files in jar
 
i have an image called left.gif and i use as so:
:

ImageIcon left = new ImageIcon("left.gif");
but when i put my source into a executable jar along with the gif the image will not show up when i run my program. if i put the gif file in the same directory as teh jar file the image will show up. how do i access the gif when i add my code and images to a executable jar file :confused:

andro Jun 11th, 2007 1:35 AM

Try:

:

ImageIcon left = new ImageIcon(getClass().getResource("left.gif"));

mrynit Jun 11th, 2007 2:08 AM

:D thank you it works:D


All times are GMT -5. The time now is 11:24 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC