-1

I have the following code and it isn't working:

import net.java.games.jogl.*;

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


public class Game {



    public static void main(String[] args) {
            // TODO Auto-generated method stub

            Frame frame = new Frame("Hello World");
            GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
            frame.add(canvas);

            frame.setSize(300, 300);
            frame.setBackground(Color.WHITE);

            frame.addWindowListener(new WindowAdapter()
            {
                public void windowClosing(WindowEvent e)
                {
                    System.exit(0);
                }
            });
            frame.show();



    }

}

The first import has an error where it does not recognise what "net" is. The error is below:

The import net cannot be resolved

The full error when I try to run the program is:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
GLCapabilities cannot be resolved to a type
The method add(Component) in the type Container is not applicable for the arguments (GLCanvas)at Game.main(Game.java:15)
Krupa Patel
  • 3,309
  • 3
  • 23
  • 28
Peter
  • 1
  • 3
  • Are you missing JOGL in the class path/library path? – PurkkaKoodari Aug 06 '14 at 11:32
  • I downloaded JOGL and put it in the files, I think it should be there :) – Peter Aug 06 '14 at 11:37
  • 1
    The sample seems to be outdated. The import should refer to `javax.media.opengl.awt.GLCanvas`. If you have an IDE like Eclipse, just press `CTRL+Shift+O` ("Oh", not zero) to organize the imports. – Marco13 Aug 06 '14 at 14:49

1 Answers1

0

You're using the very old pre-version of JOGL which is completely obsolete since (at least) 2007. Marco13 is right. Please switch to JOGL 2 (current latest version: 2.2.0) and follow these instructions: http://jogamp.org/wiki/index.php/Setting_up_a_JogAmp_project_in_your_favorite_IDE

gouessej
  • 3,640
  • 3
  • 33
  • 67