title: How Could I Import Sprite Images To A Java Eclipse Pacman Game?
body: <p>I have been writing a Pac-Man game in Java Eclipse. I have gotten the game functioning, movement, sounds, board, etc. However, one problem is that I cannot seem to get the images I used for PacMan and the ghosts to appear, resulting in both being invisible.</p>
  
  <p>I have imported all the images into my project, they are in a folder called "img" in my source file (I'm using Java Eclipse). This is in my build path and everything.</p>
  
  <p>The code I use to import the images to my game is as follows:</p>
  
  <pre><code>public class Board extends JPanel
  02
  {
  03
      Image pacmanImage = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/pacman.jpg");
  04
      Image pacmanUpImage = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/pacmanup.jpg");
  05
      Image pacmanDownImage = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/pacmandown.jpg");
  06
      Image pacmanLeftImage = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/pacmanleft.jpg");
  07
      Image pacmanRightImage = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/pacmanright.jpg");
  08
      Image ghost10 = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/ghost10.jpg");
  09
      Image ghost20 = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/ghost20.jpg");
  10
      Image ghost30 = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/ghost30.jpg");
  11
      Image ghost40 = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/ghost40.jpg");
  12
      Image ghost11 = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/ghost11.jpg");
  13
      Image ghost21 = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/ghost21.jpg");
  14
      Image ghost31 = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/ghost31.jpg");
  15
      Image ghost41 = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/ghost41.jpg");
  16
  
  17
      Image titleScreenImage =Toolkit.getDefaultToolkit().getImage("PacMan/src/img/titleScreen.jpg");
  18
      Image gameOverImage = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/gameOver.jpg");
  19
      Image winScreenImage = Toolkit.getDefaultToolkit().getImage("PacMan/src/img/winScreen.jpg");
  </code></pre>
  
  <p>Even with the code I have tried putting just <code>imgname.jpg</code> to <code>img/imagename.jpg</code>, to <code>src/img/imagename.jpg</code> to <code>projectname/src/img/imagename.jpg</code>, however, nothing seems to work.</p>
  
  <p>Any help would be appreciated. Thank you. </p>