views:

800

answers:

1

I've built a Java application which executes correctly from my IDE (Netbeans). I have packaged the jar into a bundle for Mac OS (Leopard). If I run the application from the bundle or from the shell I get this error:

java.lang.NoSuchMethodError: java.util.Properties.load(Ljava/io/Reader;)V

I'm using java 1.5.0_16.

Do you know why I get this error when I execute the jar using shell. Do you know why I don't get it when I use IDE?

Thanks!

+5  A: 

You're using Java 5, but Properties.load(Reader) was only introduced in Java 6 (aka 1.6). If this ever happens again, check the JavaDocs (e.g. the Properties JavaDoc in this case) and look at the member you're interested in - it will often give the version in which it was introduced (e.g. "Since: 1.6" in this case).

You'll need to create an InputStream instead of a Reader - or upgrade to Java 6. I suspect you'll find NetBeans is using Java 6, which is why it's working there.

Jon Skeet
To compile for an old version, set -classpath to an appropriate rt.jar, as well as using -source and -target.
Tom Hawtin - tackline