title: Embedding resources (images, sound bits, etc) into a Java project then use those resources
body: <p>I have searched for a method of embedding a resource in a java project (using Eclipse v3.6.0) then using that embedded resource within a control (e.g., <code>JLabel</code>).  I have seen methods of referencing resources from the file system.  Once the project has been developed I would like to publish the application as an executable.  It should be noted these executables will be deployed/launched to Windows, *NIX, and Linux platforms.</p>
  
  <p>I know this can be done in the Visual Studio world, but I'm very unfamiliar how to do this in Java/Eclipse IDE.  As a side question, how do I get Eclipse to create the project as a executable so it can be launched?</p>
  
  <p>Any help is greatly appreciated.</p>
  
  <p><em>Mark</em></p>
  
  <p><strong>UPDATE 1:</strong></p>
  
  <p>Based upon <a href="https://stackoverflow.com/a/3721730/98528">BalusC's response</a>, I wanted to share the code I have to resolve my problem.  My classes are under the package of "<code>Viking.Test</code>" and then I placed the image file under the package "<code>Viking.Test.Resources</code>".  This is all done within Eclipse to import the image into the project.</p>
  
  <ol>
  <li>I imported the image by right-clicking on the <em>Project -> Import -> General/File System</em> for the import source.</li>
  <li>Selected the folder which contained the image to import</li>
  <li>Selected "<code>Project/src/Viking/Test/Resources</code>" for the <em>'Into folder'</em> parameter</li>
  <li>Didn't change any of the options and clicked <em>"Finished"</em></li>
  </ol>
  
  <p>In the source file I added the following code to insert the image into a <code>JLabel</code> (<code>LblLogo</code>)</p>
  
  <pre><code>try
  {
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
    InputStream input = classLoader.getResourceAsStream(
      "Viking/Test/Resources/MyImage.jpg");
    Image logo = ImageIO.read(input);
    LblLogo = new JLabel( new ImageIcon( logo ) );
    LblLogo.setBounds(20, 11, 210, 93);
    getContentPane().add(LblLogo);
  }
  catch ( IOException e ) {  }
  </code></pre>