Java.lang.NoSuchMethodError: java.util.Properties.load (yes? Why?)

I created a Java application that runs correctly from my IDE (Netbeans). I packed the jar in the kit for Mac OS (Leopard). If I run the application from a package or from a shell, I get this error:

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

I am using java 1.5.0_16.

Do you know why I get this error when I start the jar using the shell. Do you know why I do not receive it when I use the IDE?

Thanks!

+4
source share
2 answers

You are using Java 5, but Properties.load(Reader) was introduced only in Java 6 (aka 1.6). If this happens again, check JavaDocs (for example, Properties JavaDoc in this case) and look at the participant you are interested in - it often gives the version in which it was entered (for example, “Starting at: 1.6” in this case).

You will need to create an InputStream instead of a Reader or upgrade to Java 6. I suspect you will find that NetBeans uses Java 6, so it works there.

+8
source

Only the reader supports the properties of UTF-8. We need to rewrite this method ourselves.

0
source

All Articles