Odds are the path you're giving to the file, or permissions, don't match. Put the File ctor into a try block, catch the exception, and find out what it is.
It should look something like this:
try {
File file = new File(i);
img = ImageIO.read(file);
} catch (Exception ex) {
// You probably want to open the java console, or use a logger
// as a JNLP may send stderr someplace weird.
Systemm.err.println("Exception was: ", ex.toString());
}
The code you have doesn't do anything with the exception.
You might want to look at the exceptions thread in the Java Tutorial.
update
See my comments. I just tried something and confirmed what I was thinking -- code with a try {}
and no catch
or finally
won't even compile. if this is really the code you think you're working with, you've probably been loading an old class file; this one hasn't compiled.
$ cat Foo.java
public class Foo {
public void tryit() {
try {
File f = new File(null);
}
}
}
$ javac Foo.java
Foo.java:3: 'try' without 'catch' or 'finally'
try {
^
1 error
$