title: How to create a org.eclipse.swt.graphics.Image from a external JAR
body: <p><strong>Question:</strong></p>
  
  <p>I would like to know how to create an <strong>org.eclipse.swt.graphics.Image</strong> object from a .gif in an external .jar file.</p>
  
  <p><strong>Back Ground:</strong></p>
  
  <p>I am creating a TreeViewer based on <a href="http://www.eclipse.org/articles/Article-TreeViewer/TreeViewerArticle.htm" rel="nofollow">TreeViewerArticle</a>, and would like to reference a picture in the <a href="http://jt400.sourceforge.net/" rel="nofollow">jt400.jar file</a> for one of my tree elements.</p>
  
  <p><strong>Code Snippet:</strong></p>
  
  <pre><code>class ViewLabelProvider extends LabelProvider {
  
     public Image getImage(Object obj) {
  
        &lt;&lt;&lt;&lt;NEED CODE to create org.eclipse.swt.graphics.Image &gt;&gt;&gt;&gt;
  
     }
  } 
  </code></pre>
  
  <p><strong>Solution:</strong></p>
  
  <pre><code>InputStream stream = this.getClass().getClassLoader().getResourceAsStream("/com/ibm/as400/access/AS40016.gif");
  ImageData id = new ImageData(stream);
  Image image = new Image(null, id);
  return image;
  </code></pre>