I'm interested in learning JBox2D, but I seem to have stumbled at the first hurdle - building the library.
The Quick-start instructions specify the following simple steps:
I've checked out the code and imported the project in to IntelliJ IDEA (12.1.4), however, when I try to run the TestbedMain class (and it subsequently compiles the code) I get the following errors:
java: duplicate class: org.jbox2d.common.PlatformMathUtils
java: duplicate class: org.jbox2d.common.Timer
What am I doing wrong/have I missed?
Thanks
Looking at the POM for the jbox2d-library module, I see that there is a build section which explicitly ignores the classes under the gwtemul package:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/gwtemul/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
It seems to me that I should probably be building this library through MVN and attaching the built JAR as a dependency for the jbox2d-testbed module.
However, I found that modifying the package declaration for these classes also solves the problem:
package org.jbox2d.gwtemul.org.jbox2d.common;
/**
* A GWT-compatible implementation of the platform math utilities.
*/
class PlatformMathUtils {
public static final float fastPow(float a, float b) {
return (float) Math.pow(a, b);
}
}
And since they would have been ignored by the build anyway, I don't see that it causes any harm.
Once I did this, I was able to run the org.jbox2d.testbed.framework.TestbedMain class and I get the expected GUI: