title: What is the correct path for Toolkit.getImage()?
body: <p>I need to upload an image file and generate a thumbnail for the uploaded file in my JSF webapplication. The original image is stored on the server in <code>/home/myname/tomcat/webapps/uploads</code>, while the thumbnail is stored in <code>/home/myname/tomcat/webapps/uploads/thumbs</code>. I'm using the thumbnail generator class I copied from <a href="http://www.philreeve.com/java_high_quality_thumbnails.php" rel="nofollow">philreeve.com</a>.</p>
  
  <p>I have successfully uploaded the file with help from <a href="http://balusc.blogspot.com/2008/02/uploading-files-with-jsf.html" rel="nofollow">BalusC</a>. But using <code>Toolkit.getImage()</code>, I can't access the image.</p>
  
  <p>I used the uploaded file's absolute path, like so:</p>
  
  <pre><code>inFilename = file.getAbsolutePath();
  </code></pre>
  
  <p>The relevant code from the thumbnail generator is:</p>
  
  <pre><code>public static String createThumbnail(String inFilename, String outFilename, int largestDimension) {
      ...
      Image inImage = Toolkit.getDefaultToolkit().getImage(inFilename);
      if (inImage.getWidth(null) == -1 || inImage.getHeight(null) == -1) {
          return "Error loading file: \"" + new File(inFilename).getAbsolutePath() + "\"";
      }
      ...
  }
  </code></pre>
  
  <p>Since I am already using the absolute path, I don't understand why it is not working. I have also used the following values for <code>inFilename</code>, but I always get the "Error loading file...".</p>
  
  <ul>
  <li><code>/home/myname/tomcat/webapps/uploads/filename.ext</code></li>
  <li><code>/uploads/filename.ext</code></li>
  </ul>
  
  <p>But I did check the directory, and the image <em>is</em> there. (I uploaded using <code>/home/myname/tomcat/webapps/uploads/filename.ext</code>, and it works.) What is the correct path for the image in that directory? Thank you.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I got the code to work by using:</p>
  
  <pre><code>Image inImage = ImageIO.read(new File(inFilename));
  </code></pre>
  
  <p>I still don't understand why <code>Toolkit.getImage()</code> does not work though.</p>