tamas.mahr
tamas.mahr

Reputation: 23

java.lang.NoSuchMethodError: javax.media.opengl.GLDrawableFactory.initSingleton()V

I am trying to use the JZY3D libraries in my Java project.

Starting with the basic, I set up the following main():

public static void main(final String[] args) {
  new GLCapabilities(GLProfile.getDefault());
}

The jogl-all.jar, gluegen-rt.jar and gluegen.jar files are in the build path. I get the following exception:

Exception in thread "main" java.lang.NoSuchMethodError: javax.media.opengl.GLDrawableFactory.initSingleton()V
    at javax.media.opengl.GLProfile.initProfilesForDefaultDevices(GLProfile.java:1444)
    at javax.media.opengl.GLProfile.access$100(GLProfile.java:76)
    at javax.media.opengl.GLProfile$1.run(GLProfile.java:174)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.media.opengl.GLProfile.initSingleton(GLProfile.java:140)
    at javax.media.opengl.GLProfile.initSingleton(GLProfile.java:199)
    at javax.media.opengl.GLProfile.getProfileMap(GLProfile.java:1914)
    at javax.media.opengl.GLProfile.get(GLProfile.java:815)
    at javax.media.opengl.GLProfile.getDefault(GLProfile.java:602)
    at javax.media.opengl.GLProfile.getDefault(GLProfile.java:613)
    at eu.crisis_economics.abm.model.SpecsCompetitionStrategyCFO.main(SpecsCompetitionStrategyCFO.java:312)

It seems like there is a problem with the 3d libraries, but I cannot figure out what.

Upvotes: 2

Views: 2601

Answers (2)

xranby
xranby

Reputation: 596

The jogl-all.jar, gluegen-rt.jar and gluegen.jar files are in the build path. I get the following exception:

Remove gluegen.jar from the build path. Make sure these two jars are added to the classpath at runtime as well! You only need jogl-all.jar and gluegen-rt.jar (rt == runtime) at compile time and runtime.

Also you need to have a copy of the matching native jars gluegen-rt-natives-os.and.arch.jar and jogl-all-natives-os.and.arch.jar for the platform you use next to the gluegen-rt.jar and jogl-all.jar http://jogamp.org/jogl/doc/deployment/JOGL-DEPLOYMENT.html#NativeJARFiles

Upvotes: 2

Rigi
Rigi

Reputation: 1

Have you tried the Maven dependency instead of add those jars by hand?

I made a clean maven project, add a new user library with the following files:

  • org.jzy3d-0.9.jar
  • dependencies/misc/opencsv-2.1.jar
  • dependencies/misc/org.convexhull.jar
  • dependencies/misc/swt.jar
  • dependencies/misc/swt-debug.jar

After that, I add the following maven dependencies:

<dependency>
  <groupId>org.jogamp.gluegen</groupId>
  <artifactId>gluegen-rt-main</artifactId>
  <version>2.0.2</version>
</dependency>
<dependency>
  <groupId>org.jogamp.jogl</groupId>
  <artifactId>jogl-all-main</artifactId>
  <version>2.0.2</version>
</dependency>

Build & Run with no exceptions.


A much cleaner solution is:

Upvotes: 0

Related Questions