Problems compiling files using JOGL

∥☆過路亽.° 提交于 2019-12-24 04:29:10

问题


I'm trying to get a simple program using JOGL to compile via the command line. This isn't really working. I've tried referencing jogl.all.jar, gluegen-rt.jar, nativewindow.all.jar, and newt.all.jar as the official documentation suggested, but the compiler still cannot find the JOGL classes.

This is the code:

import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLEventListener;

public class Test implements GLEventListener {

    public static void main(String[] args) {
        Frame frame = new Frame("JOGL Test");
        GLCanvas canvas = new GLCanvas();
        canvas.addGLEventListener(new Test());
        frame.add(canvas);
        frame.setSize(300, 300);
        frame.setVisible(true);
        frame.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
    }

    public void init(GLAutoDrawable drawable) {
    }

    public void reshape(GLAutoDrawable drawable, int x, int y, int width,
            int height) {
    }

    public void display(GLAutoDrawable drawable) {
        GL gl = drawable.getGL();
        gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        gl.glClear(GL.GL_COLOR_BUFFER_BIT);
        gl.glColor3f(1.0f, 1.0f, 1.0f);
        gl.glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
        gl.glBegin(GL.GL_POLYGON);
        gl.glVertex2f(-0.5f, -0.5f);
        gl.glVertex2f(-0.5f, 0.5f);
        gl.glVertex2f(0.5f, 0.5f);
        gl.glVertex2f(0.5f, -0.5f);
        gl.glEnd();
        gl.glFlush();
    }

    public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
            boolean deviceChanged) {
    }

}

This is what I'm using to compile it:

javac -cp /jogl/lib/jogl.all.jar;/jogl/lib/gluegen-rt.jar;/jogl/lib/nativewindow.all.jar;/jogl/lib/newt.all.jar Test.java

The java compiler seems to be ignoring my classpath specifications entirely.

Edit: It seems to be fine about GL, GLAutoDrawable, and GLEventListener, just it can't find GLCanvas. Taking a look inside jogl.all.jar, it seems that GLCanvas.class is not there.


回答1:


Try each of these and see if one works:

javac -cp \jogl\lib\jogl.all.jar;\jogl\lib\gluegen-rt.jar;\jogl\lib\nativewindow.all.jar;\jogl\lib\newt.all.jar Test.java

javac -cp ./jogl/lib/jogl.all.jar;./jogl/lib/gluegen-rt.jar;./jogl/lib/nativewindow.all.jar;./jogl/lib/newt.all.jar Test.java

javac -cp .\jogl\lib\jogl.all.jar;.\jogl\lib\gluegen-rt.jar;.\jogl\lib\nativewindow.all.jar;.\jogl\lib\newt.all.jar Test.java



回答2:


Don't forget to use the os specific separators ("\" and ";" under Windows, "/" and ":" under Linux) and now jogl.all.jar has been renamed jogl-all.jar. You only need to put jogl-all.jar and gluegen-rt.jar in your classpath. gluegen-rt-natives-?-?.jar and jogl-all-natives-?-?.jar must be in the same directory but not in the classpath.



来源:https://stackoverflow.com/questions/1982152/problems-compiling-files-using-jogl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!