Writing applet to launch in JNLPLauncher

Hi,

I have an urgent need to launch an application which loads a 3d model in browser.

As practice, I tried the gears demo from https://jogl-demos.dev.java.net/applettest.html. I could successfully launch it with the jogl-demos.jar saved in my IIS server.

I am trying to write an applet for the JOGLTetrahedron demo in wikipedia http://en.wikipedia.org/wiki/Java_OpenGL. Also I am not sure about creating the jar file and signing it.
Can someone please guide me with the code for the applet and how to jar it.

thanks,
SSS

not necessary to sign the applet, the jogl and joal libraries are trusted.
normal jar export should be ok
the main thing is to have the jnlp file setup right
and launch with <applet code=“org.jdesktop.applet.util.JNLPAppletLauncher” settings figured out.

thanks Karmington.

I am doing as you say. When I open the html, it starts the jnlpapplet launcher, says applet started but does not show the applet.

Can you please tell where I am going wrong.

Following is the modified JOGLTetrahedron.java which compiles and runs fine.


package demos.tetra;
import javax.media.opengl.GL;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.glu.GLU;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.media.opengl.GLCanvas;
import java.awt.Frame;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import com.sun.opengl.util.Animator;
 
public class JOGLTetrahedron implements GLEventListener, KeyListener {
public static void main(String[] args) {
    Frame frame = new Frame("Gear Demo");
    GLCanvas canvas = new GLCanvas();
	
    canvas.addGLEventListener(new JOGLTetrahedron());
    frame.add(canvas);
    frame.setSize(300, 300);
    final Animator animator = new Animator(canvas);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
          // Run this on another thread than the AWT event queue to
          // make sure the call to Animator.stop() completes before
          // exiting
          new Thread(new Runnable() {
              public void run() {
                animator.stop();
                System.exit(0);
              }
            }).start();
        }
      });
    frame.show();
    animator.start();
  }

 float rotateT = 0.0f;
static GLU glu = new GLU();

public void init(GLAutoDrawable gLDrawable) {
	GL gl = gLDrawable.getGL();
	gl.glShadeModel(GL.GL_SMOOTH);
	gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
	gl.glClearDepth(1.0f);
	gl.glEnable(GL.GL_DEPTH_TEST);
	gl.glDepthFunc(GL.GL_LEQUAL);
	gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, 
		  GL.GL_NICEST);
	gLDrawable.addKeyListener(this);
    }

public void reshape(GLAutoDrawable gLDrawable, int x, 
			int y, int width, int height) {
	GL gl = gLDrawable.getGL();
	if(height <= 0) {
	    height = 1;
	}
	float h = (float)width / (float)height;
	gl.glMatrixMode(GL.GL_PROJECTION);
	gl.glLoadIdentity();
	glu.gluPerspective(50.0f, h, 1.0, 1000.0);
	gl.glMatrixMode(GL.GL_MODELVIEW);
	gl.glLoadIdentity();
    }

 public void display(GLAutoDrawable gLDrawable) {
	final GL gl = gLDrawable.getGL();
	gl.glClear(GL.GL_COLOR_BUFFER_BIT);
	gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
	gl.glLoadIdentity();
	gl.glTranslatef(0.0f, 0.0f, -5.0f);
 
	gl.glRotatef(rotateT, 1.0f, 0.0f, 0.0f);
	gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
	gl.glRotatef(rotateT, 0.0f, 0.0f, 1.0f);
	gl.glRotatef(rotateT, 0.0f, 1.0f, 0.0f);
 
	gl.glBegin(GL.GL_TRIANGLES);
 
	// Front
	gl.glColor3f(0.0f, 1.0f, 1.0f); 
	gl.glVertex3f(0.0f, 1.0f, 0.0f);
	gl.glColor3f(0.0f, 0.0f, 1.0f); 
	gl.glVertex3f(-1.0f, -1.0f, 1.0f);
	gl.glColor3f(0.0f, 0.0f, 0.0f); 
	gl.glVertex3f(1.0f, -1.0f, 1.0f);
 
	// Right Side Facing Front
	gl.glColor3f(0.0f, 1.0f, 1.0f); 
	gl.glVertex3f(0.0f, 1.0f, 0.0f);
	gl.glColor3f(0.0f, 0.0f, 1.0f); 
	gl.glVertex3f(1.0f, -1.0f, 1.0f);
	gl.glColor3f(0.0f, 0.0f, 0.0f); 
	gl.glVertex3f(0.0f, -1.0f, -1.0f);
 
	// Left Side Facing Front
	gl.glColor3f(0.0f, 1.0f, 1.0f); 
	gl.glVertex3f(0.0f, 1.0f, 0.0f);
	gl.glColor3f(0.0f, 0.0f, 1.0f); 
	gl.glVertex3f(0.0f, -1.0f, -1.0f);
	gl.glColor3f(0.0f, 0.0f, 0.0f); 
	gl.glVertex3f(-1.0f, -1.0f, 1.0f);
 
	// Bottom
	gl.glColor3f(0.0f, 0.0f, 0.0f); 
	gl.glVertex3f(-1.0f, -1.0f, 1.0f);
	gl.glColor3f(0.1f, 0.1f, 0.1f); 
	gl.glVertex3f(1.0f, -1.0f, 1.0f);
	gl.glColor3f(0.2f, 0.2f, 0.2f); 
	gl.glVertex3f(0.0f, -1.0f, -1.0f);
 
	gl.glEnd();
 
	rotateT += 0.2f;
    }

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

public void keyPressed(KeyEvent e) {
	if(e.getKeyCode() == KeyEvent.VK_ESCAPE) {
	    System.exit(0);
	}
    }
 
    public void keyReleased(KeyEvent e) {
    }
 
    public void keyTyped(KeyEvent e) {
    }
 
}

Applet code:


package demos.applets;
import javax.media.opengl.*;
import com.sun.opengl.util.*;
import demos.tetra.JOGLTetrahedron;

/** Shows how to deploy an applet using JOGL. This demo must be
    referenced from a web page via an &lt;applet&gt; tag. */

public class TetraApplet extends Applet {
  private Animator animator;

  public void init() {
    setLayout(new BorderLayout());
    GLCanvas canvas = new GLCanvas();
    canvas.addGLEventListener(new JOGLTetrahedron());
    canvas.setSize(getSize());
    add(canvas, BorderLayout.CENTER);
    animator = new FPSAnimator(canvas, 60);
  }

  public void start() {
    animator.start();
  }

  public void stop() {
    // FIXME: do I need to do anything else here?
    animator.stop();
  }
}

My tetra.jar file has the class files for the above two and I have it in IIS
Following is the html,

Applet example
</BODY>

I would greatly appreciate if you could help me out.

thanks.

ok, comparing it to my version i see at least one difference:

missing this line as last param

and the jnlp file has

<?xml version="1.0" encoding="utf-8"?> applet blahblah. hrefs to the external jars

P.S. how to make the code

here?