title: How to add image using getResource() in NetBeans in a Maven project
body: <p>I am trying to add images using this code in NetBeans but the image is not getting added <br />
  I have used multiple ways by adding '/' in front of res but it is still not working<br /></p>
  <p>This is the file structure <br /></p>
  <pre><code>--src
    -res(inside src folder)
      -imgglug(inside res folder)
        -blue.png(inside imgglug folder)
        -no2.png
         ..(more png images are stored in imgglug folder)
  </code></pre>
  <hr />
  <pre><code>private void loadNumberTiles()
  {
    numberTiles=new Hashtable();
   
    ClassLoader cldr=this.getClass().getClassLoader();
   java.net.URL url0000=cldr.getResource(&quot;res/imgglug/blue.png&quot;);
   java.net.URL url0002=cldr.getResource(&quot;res/imgglug/no2.png&quot;);
   java.net.URL url0004=cldr.getResource(&quot;res/imgglug/no4.png&quot;);
   java.net.URL url0008=cldr.getResource(&quot;res/imgglug/no8.png&quot;);
   java.net.URL url0016=cldr.getResource(&quot;res/imgglug/no16.png&quot;);
   java.net.URL url0032=cldr.getResource(&quot;res/imgglug/no32.png&quot;);
   java.net.URL url0064=cldr.getResource(&quot;res/imgglug/no64.png&quot;);
   java.net.URL url0128=cldr.getResource(&quot;res/imgglug/no128.png&quot;);
   java.net.URL url0256=cldr.getResource(&quot;res/imgglug/no256.png&quot;);
   java.net.URL url0512=cldr.getResource(&quot;res/imgglug/no.512.png&quot;);
   java.net.URL url1024=cldr.getResource(&quot;res/imgglug/no.1024.png&quot;);
   java.net.URL url2048=cldr.getResource(&quot;res/imgglug/no.2048.png&quot;);
   if(url0000!=null)
       {
           numberTiles.put(0,new ImageIcon(url0000));
       }
       if(url0002!=null)
               {
                  numberTiles.put(2,new ImageIcon(url0002)); 
               }
       if(url0004!=null)
               {
                  numberTiles.put(4,new ImageIcon(url0004)); 
               }
       if(url0008!=null)
               {
                   numberTiles.put(8,new ImageIcon(url0008));
               }
       if(url0016!=null)
               {
                   numberTiles.put(16,new ImageIcon(url0016));
               }
       if(url0032!=null)
               {
                   numberTiles.put(32,new ImageIcon(url0032));
               }
       if(url0064!=null)
               {
                   numberTiles.put(64,new ImageIcon(url0064));
               }
       if(url0128!=null)
               {
                    numberTiles.put(128,new ImageIcon(url0128));
               }
       if(url0256!=null)
               {
                   numberTiles.put(256,new ImageIcon(url0256));
               }
       if(url0512!=null)
               {
                   numberTiles.put(512,new ImageIcon(url0512));
               }
       
       if(url1024!=null)
               {
                   numberTiles.put(1024,new ImageIcon(url1024));
               }
       if(url2048!=null)
               {
                   numberTiles.put(2048,new ImageIcon(url2048));
               } }
  </code></pre>