I am using Eclipse IDE.
In my project A, I am making use of another project B. So I made a jar of B and placed in A's build path. Now, when I make use of B's class, I am getting an NoSuchMethodError as follows:
Exception in thread "main" java.lang.NoSuchMethodError: org.semanticweb.owlapi.util.OWLEntityCollector.<init>(Ljava/util/Set;)V
I place OWL API jar file which supports that method i.e. OWLEntityCollector's constructor takes a parameter of type Set<Entity>. By default, in Eclipse, all the jars in the build path are in the classpath as well.
That suggests that the version of the class the compiler used is not the same as the version the JVM is using, and the JVM is using one that doesn't have that constructor defined. If you've definitely put the right JAR file on the classpath, then maybe there's another JAR also containing that class that's causing a conflict.
You are right, there is indeed another jar which I make use of, that contains the same class minus the one parameter constructor. Now, how can I make sure that one jar is give precedence over the other jar? (in Eclipse and in general)