Hello Guest

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

  • 3 Replies
  • 2712 Views
[BUG]? Cannot get applet running on Windows [SOLVED]
« on: February 05, 2015, 15:46:15 »
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.

Code: [Select]
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
Code: [Select]
<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
Code: [Select]
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

Code: [Select]
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.




« Last Edit: February 06, 2015, 17:56:50 by thefrog »

*

Offline abcdef

  • ****
  • 320
Re: [BUG]? Cannot get applet running on Windows
« Reply #1 on: February 05, 2015, 20:29:33 »
This is a classic classpath issue, add the rest of the lwjgl jars to 
Code: [Select]
archive="lib/lwjgl_util_applet.jar" in the applet definition.

Re: [BUG]? Cannot get applet running on Windows
« Reply #2 on: February 06, 2015, 08:27:43 »
Thanks for your reply.

I've added
Code: [Select]
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.


Re: [BUG]? Cannot get applet running on Windows
« Reply #3 on: February 06, 2015, 17:56:23 »
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
Code: [Select]
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.