mahdi68 -4 Junior Poster in Training

Hi ,
i have problem to run my code in eclipse !!! whene i run this code on netbeans it`s successful runs but on eclipse this error is shown :

Null Pointer java/lang/NullPointer Exeption
1.   import java.io.IOException;  
   2.   
   3. import javax.microedition.lcdui.Canvas;  
   4. import javax.microedition.lcdui.Graphics;  
   5. import javax.microedition.lcdui.Image;  
   6.   
   7.   
   8. public class MapCanvas extends Canvas{  
   9.     Image x = null;  
  10.   
  11.     public MapCanvas() {  
  12.         try {  
  13.             x = Image.createImage("/1.jpg");  
  14.         } catch (IOException e) {  
  15.             // TODO Auto-generated catch block  
  16.             e.printStackTrace();  
  17.         }  
  18.     }  
  19.   
  20.     protected void paint(Graphics arg0) {  
  21.         // TODO Auto-generated method stub  
  22.         arg0.drawImage(x, getWidth()/2, getHeight()/2, 3);  
  23.           
  24.     }  
  25.   
  26. }  
  27.

i copy image file (1.jpg) in res directory . i know problem is here

x = Image.createImage("/1.jpg");

but i dont know why ???can any body help to me ???
thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.