NoSuchMethodError, even though method is clearly there

Hi all,

I'm writing a program using Eclipse. The program uses a third-party jar, which I have added to the project's build path.

In Eclipse, if you write out an object's name and then hit the period (.), you get a list of all the methods. Using this, I scroll down to the method "getName()", which takes no arguments.

To be sure, I also open the jar in Eclipse, open the Java class that the object belongs to, and note that the method "getName()" exists (even though I can't see the source itself, naturally).

Eclipse accepts the line with no errors.

However, when I run the program from Eclipse, I get the error

Exception in thread"Thread-2" java.lang.NoSuchMethodError:

edu.colorado.phet.common.application.PhetApplication.getName()Ljava/lang/String;

at org.concord.otrunkphet.sound.OTPhetSoundModelView$startWaveInterferenceApplication.run(OTPhetSoundModelView.java:72)

at java.lang.Thread.run(Thread.java:613)

How can I get a NoSuchMethodError when both Eclipse and I see the method in the jar?

Any help much appreciated,

Sam

[1141 byte] By [Asbestosa] at [2007-11-27 3:45:25]
# 1

Ok, well... It turned out that I was using two jars, both of which shared some common packages, but which unfortunately did not share the same VERSIONS of the packages.

I need both jars, because I need some of the classes from one jar and some of the clases from the other (appart from the common packages, they are not the same).

I thought I could solve this by the order of the jars in my build path, but if I switch this then there are other parts of my code that break.

Am I right in thinking that there is no way to specify which jar to get a class from, when the class is in both jars?

If not, I guess I'll have to split my code into two different projects or something....

Asbestosa at 2007-7-12 8:49:08 > top of Java-index,Java Essentials,Java Programming...
# 2

>

> Am I right in thinking that there is no way to

> specify which jar to get a class from, when the class

> is in both jars?

>

Sounds like a really bad idea to me regardless of whether an implementation exists.

If you need to use, not mix, different versions then that is doable.

jschella at 2007-7-12 8:49:08 > top of Java-index,Java Essentials,Java Programming...