I’m trying to run the Desmo-J simulation sample in Java, NetBeans 7.2 on a Mac OS X 10.7.
A class called TimeSeries is included as an import ie.
import desmoj.core.statistic.TimeSeries;
It has a function signature of
(Model, String, TimeInstant,TimeInstant, boolean)
I can compile my main java file OK, but when running/debugging, it fails, telling me
Exception in thread "main" java.lang.NoSuchMethodError: desmoj.core.statistic.TimeSeries.<init>(Ldesmoj/core/simulator/Model;Ljava/lang/String;Ldesmoj/core/simulator/TimeInstant;Ldesmoj/core/simulator/TimeInstant;Z)V
This is despite the fact the call I’m making (AFAIK) passes exactly the right typed parameters:
trucksArrived = new TimeSeries(this.getModel(), "arrived", new TimeInstant(0), new TimeInstant(1500), false);
trucksServiced = new TimeSeries(this.getModel(), "finished", new TimeInstant(0), new TimeInstant(1500), false);
I’m stumped as to why this might be happening. Any clues on why Java would be unable to recognise my method call at runtime, while seeing it fine in the compile?
Could it be something interfering on the classpath ie. another TimeSeries out there (can’t see any at the moment in the libs)? Have I read the exception message (with its function signature) properly? Some of the methods in TimeSeries are deprecated (though not the ones I’m using). Could that interfere with things perhaps?
Thanks guys
Pete
You are trying to use a constructor with the signature:
which should match this one.
The fact that your compile is succeeding but the program is giving this runtime error strongly suggest that your application is using a different version of the library at runtime than the version that you compiled against. Check the following:
Check that you have the same desmoj JAR on your build classpath and your run classpath.
Check that you haven’t accidentally included two versions of the desmoj JAR on either classpath.