[BUG]? Cannot get applet running on Windows [SOLVED]

Started by thefrog, February 05, 2015, 15:46:15

Previous topic - Next topic

thefrog

Hello everyone,

I cannot get an applet to run with LWJGL 2.9.3 and Java 1.8.0.31.
I made a simple applet wich runs in netbeans no problem.

package lwjglappletExample;
import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Canvas;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;

public class LwjglAppletExample extends Applet{
	Canvas display_parent;
	Thread gameThread;
	boolean running = false;
        float r=0,r2=0,r3=0;
 
	public void startLWJGL() {
		gameThread = new Thread() {
			public void run() {
				running = true;
				try {
					Display.setParent(display_parent);
					Display.create();
					initGL();
				} catch (LWJGLException e) {
					e.printStackTrace();
					return;
				}
				gameLoop();
			}
		};
		gameThread.start();
	}
 
	private void stopLWJGL() {
		running = false;
		try {
			gameThread.join();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
	}
 
	public void start() {
 
	}
 
	public void stop() {
 
	}
 
	public void destroy() {
		remove(display_parent);
		super.destroy();
	}
 
	public void init() {
		setLayout(new BorderLayout());
		try {
			display_parent = new Canvas() {
				public final void addNotify() {
					super.addNotify();
					startLWJGL();
				}
				public final void removeNotify() {
					stopLWJGL();
					super.removeNotify();
				}
			};
			display_parent.setSize(getWidth(),getHeight());
			add(display_parent);
			display_parent.setFocusable(true);
			display_parent.requestFocus();
			display_parent.setIgnoreRepaint(true);
			setVisible(true);
		} catch (Exception e) {
			System.err.println(e);
			throw new RuntimeException("Unable to create display");
		}
	}
 
	protected void initGL() {
             // init OpenGL
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, 800, 0, 600, 1, -1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
	}
 
	public void gameLoop() {

            while(running) {
                     GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);  
        r+=0.1f;
//        r2+=0.01f;
//        r3+=0.3f;
        
        GL11.glColor3f(0.5f,0.5f,1.0f);
        GL11.glPushMatrix();
        GL11.glTranslatef(400f,300f,0f);
        GL11.glRotatef(r,0f,0f,1f);
        GL11.glScalef(1.2f,1.2f,1.2f);
        drawQuad();
        GL11.glPopMatrix();


        Display.sync(60);
	Display.update();
		}
 
		Display.destroy();
	}    
        void drawQuad() {
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2f(-100,-100);
        GL11.glVertex2f(100,-100);
        GL11.glVertex2f(100,100);
        GL11.glVertex2f(-100,100);
        GL11.glEnd();
        }    
}


Here is the html applet tag to run the applet
<applet 
	code="org.lwjgl.util.applet.AppletLoader" archive="lib/lwjgl_util_applet.jar"
	codebase="http://www.lagence3d.com/~dressingtest/"

<param name="java_arguments" value="-Xms256m -Xmx512m">
<param name="al_title" value="Test Applet LWJGL">
<param name="al_jars" value="LwjglAppletExample.jar, lib/lwjgl.jar,lib/lwjgl_util.jar,lib/lwjgl_util_applet.jar,lib/lwjgl-debug.jar">
<param name="al_main" value="lwjglappletExample.LwjglAppletExample">
<param name="progressbar" value="true">
<param name="al_windows" value="lib/windows.jar">
<param name="al_debug" value="true">

</applet>


All jars are signed with a valid certificate. The manifest of the main Jar, contains all the required entries
Application-Name: LWJGL Applet Example
Permissions: all-permissions
Codebase: http://www.lagence3d.com
Application-Library-Allowable-Codebase: http://www.lagence3d.com
Caller-Allowable-Codebase: http://www.lagence3d.com


The natives are correctly deployed in
C:\Users\[MyName]\AppData\Local\Temp\lwjglcache\www.lagence3d.com\Test Applet LWJGL\natives
I see the lwjgl logo and progress bar

Here is the error I get

Checking version
Determining packages to load
Calculating download size
Checking for updates
Downloading packages
Extracting downloaded packages
Extracting downloaded packages
Validating packages
Updating classpath
Switching applet
Initializing real applet
Starting real applet
Done loading
Exception in thread "Thread-37" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLUtil
	at org.lwjgl.util.applet.AppletLoader$4.findLibrary(AppletLoader.java:1224)
	at java.lang.ClassLoader.loadLibrary(Unknown Source)
	at java.lang.Runtime.loadLibrary0(Unknown Source)
	at java.lang.System.loadLibrary(Unknown Source)
	at org.lwjgl.opengl.WindowsCanvasImplementation$1.run(WindowsCanvasImplementation.java:57)
	at java.security.AccessController.doPrivileged(Native Method)
	at org.lwjgl.opengl.WindowsCanvasImplementation.<clinit>(WindowsCanvasImplementation.java:54)
	at org.lwjgl.opengl.AWTGLCanvas.createImplementation(AWTGLCanvas.java:96)
	at org.lwjgl.opengl.AWTGLCanvas.<clinit>(AWTGLCanvas.java:88)
	at org.lwjgl.opengl.WindowsDisplay.getHwnd(WindowsDisplay.java:296)
	at org.lwjgl.opengl.WindowsDisplay.createWindow(WindowsDisplay.java:230)
	at org.lwjgl.opengl.Display.createWindow(Display.java:306)
	at org.lwjgl.opengl.Display.create(Display.java:848)
	at org.lwjgl.opengl.Display.create(Display.java:757)
	at org.lwjgl.opengl.Display.create(Display.java:739)
	at lwjglappletExample.LwjglAppletExample$1.run(LwjglAppletExample.java:38)


I canââ,¬â,,¢t see what I've done wrong. Iââ,¬â,,¢ve tried many things, playing with the codebase, add other lwjgl jars, using older version of lwjgl (9.2 & 9.1) but to no avail.

I wonder if someone could provide a demo of a working applet page

Thanks for your help and your time.





abcdef

This is a classic classpath issue, add the rest of the lwjgl jars to 
archive="lib/lwjgl_util_applet.jar"
in the applet definition.

thefrog

Thanks for your reply.

I've added
archive="lib/lwjgl_util_applet.jar, LwjglAppletExample.jar, lib/lwjgl.jar, lib/lwjgl_util.jar"

But I still get the same error message, The difference is I get the message sooner now. On the first line of the console.


thefrog

Ok, so this is how I got it working.

Downloaded the source of the applet launcher 2.9.1
Modified the manifest to add my server name
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Application-Name: LWJGL Applet Loader
Permissions: all-permissions
Codebase: http://www.lagence3d.com
Application-Library-Allowable-Codebase: http://www.lagence3d.com
Caller-Allowable-Codebase: http://www.lagence3d.com

Recompiled
Signed

And that's it.

So if I got things right, It means you cannot use the applet launcher as-is, you have to modify the manifest (?)
The original line in the manifest "Codebase: * " seemed to cause the problem.