<p>I am reading image files in Java using</p>

<pre><code>java.awt.Image img = Toolkit.getDefaultToolkit().createImage(filePath);
</code></pre>

<p>On some systems this doesn't work, it instead throws an AWTError complaining about sun/awt/motif/MToolkit.</p>

<p>How else can you create a java.awt.Image object from an image file?</p>

I read images using
ImageIO
.
```
```
Image i = ImageIO.read(InputStream in);
```
```
The javadoc will offer more info as well.