[SOLVED] Migration from 2.0 to 2.3.1, Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME
Posted by Djak on Sep 19, 2015; 11:01am
URL: https://forum.jogamp.org/SOLVED-Migration-from-2-0-to-2-3-1-Exception-in-thread-main-java-lang-NoSuchFieldError-DEBUG-STATS-FE-tp4035330.html
Hi :)
I'd like to migrate an engine from JOGL 2.0 to 2.3.1 and I have some difficulties so I tried the base test code of OneTrianleAWT:
----
package gengine2d.jogl;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import com.jogamp.opengl.GL;
import com.jogamp.opengl.GL2;
import com.jogamp.opengl.GLAutoDrawable;
import com.jogamp.opengl.GLCapabilities;
import com.jogamp.opengl.GLEventListener;
import com.jogamp.opengl.GLProfile;
import com.jogamp.opengl.awt.GLCanvas;
import com.jogamp.opengl.glu.GLU;
public class MainOneTriangleAWT {
protected static void setup( GL2 gl2, int width, int height ) {
gl2.glMatrixMode( GL2.GL_PROJECTION );
gl2.glLoadIdentity();
// coordinate system origin at lower left with width and height same as the window
GLU glu = new GLU();
glu.gluOrtho2D( 0.0f, width, 0.0f, height );
gl2.glMatrixMode( GL2.GL_MODELVIEW );
gl2.glLoadIdentity();
gl2.glViewport( 0, 0, width, height );
}
protected static void render( GL2 gl2, int width, int height ) {
gl2.glClear( GL.GL_COLOR_BUFFER_BIT );
// draw a triangle filling the window
gl2.glLoadIdentity();
gl2.glBegin( GL.GL_TRIANGLES );
gl2.glColor3f( 1, 0, 0 );
gl2.glVertex2f( 0, 0 );
gl2.glColor3f( 0, 1, 0 );
gl2.glVertex2f( width, 0 );
gl2.glColor3f( 0, 0, 1 );
gl2.glVertex2f( width / 2, height );
gl2.glEnd();
}
public static void main( String [] args ) {
GLProfile glprofile = GLProfile.getDefault();
GLCapabilities glcapabilities = new GLCapabilities( glprofile );
final GLCanvas glcanvas = new GLCanvas( glcapabilities );
glcanvas.addGLEventListener( new GLEventListener() {
@Override
public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) {
setup( glautodrawable.getGL().getGL2(), width, height );
}
@Override
public void init( GLAutoDrawable glautodrawable ) {
}
@Override
public void dispose( GLAutoDrawable glautodrawable ) {
}
@Override
public void display( GLAutoDrawable glautodrawable ) {
render( glautodrawable.getGL().getGL2(), glautodrawable.getSurfaceWidth(), glautodrawable.getSurfaceHeight() );
}
});
final Frame frame = new Frame( "One Triangle AWT" );
frame.add( glcanvas );
frame.addWindowListener( new WindowAdapter() {
public void windowClosing( WindowEvent windowevent ) {
frame.remove( glcanvas );
frame.dispose();
System.exit( 0 );
}
});
frame.setSize( 640, 480 );
frame.setVisible( true );
}
}
-----
With this code I have this exception when running the application (using Java 7 and Windows 32bit):
---
Exception in thread "main" java.lang.NoSuchFieldError: DEBUG_STATS_FORNAME
at com.jogamp.opengl.GLProfile.initSingleton(GLProfile.java:209)
at com.jogamp.opengl.GLProfile.getProfileMap(GLProfile.java:2272)
at com.jogamp.opengl.GLProfile.get(GLProfile.java:987)
at com.jogamp.opengl.GLProfile.getDefault(GLProfile.java:721)
at com.jogamp.opengl.GLProfile.getDefault(GLProfile.java:732)
at gengine2d.jogl.MainOneTriangleAWT.main(MainOneTriangleAWT.java:48)
---
Here is what I linked to the project:
jogamp-all-platforms\jar\gluegen.jar
jogamp-all-platforms\jar\jogl-all.jar
and the natives library path for both jars:
jogamp-all-platforms\jar
I also tried gluegen-rt.jar instead of gluegen.jar but got the same exception.
(Could also anyone tell me the difference between gluegen-rt.jar and gluegen.jar ?)
Thank you in advance.
Djak
[EDIT] If I use my original code that I want to migrate :
---
MainTextsConsole jogl = new MainTextsConsole(new JOGLFixedPipelineRenderer2d(new GLCanvas()));
---
I get this error:
----
Exception in thread "main" java.lang.VerifyError: (class: com/jogamp/opengl/awt/GLCanvas, method: getContext signature: ()Lcom/jogamp/opengl/GLContext;) Wrong return type in function
at gengine2d.base.MainTextsConsole.main(MainTextsConsole.java:310)
---
due to "new GLCanvas()" call.