LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Unic on February 01, 2008, 15:32:26

Title: Problem with Applet
Post by: Unic on February 01, 2008, 15:32:26
Hello,

First of all: Please excuse my terrible english, I am from germany!

I started learning LWJGL two days ago and apart from a little error i made when I was trying to compile the code I had no Problems.
I tested this (http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/applet) example of an Applet in Eclipse and it worked (I saw a little square spinning around), but when i put it on my Webspace i got a Problem:
Exception in thread "Thread-2" java.lang.NoClassDefFoundError: org/lwjgl/opengl/AWTGLCanvas
It seems, that the natives can not be found on my Webspace and I dont know why.

What I've done:

1. I have compiled the Class "GLApplet.class" which contains the Code.

2. I downloaded the files "windows_natives.jar", "linux_natives.jar", "macosx_natives.jar"

3. I wrote a MANIFEST.MF for my jar I've loaded up containing the following code:
Manifest-Version: 1.0
Class-Path: lib/windows_natives.jar lib/linux_natives.jar lib/macosx_natives.jar



4. I made my jar by typing the following command to the Console:
jar cmf MANIFEST.MF test.jar GLApplet.class lib

5. I startet the keytool from Java by typing th following command to the Console:
keytool -alias test -genkey
then I followed the instructions given to me by the Keytool and everything seemed to be right.

6. I signed my test.jar by typing the following command to the console:
jarsigner test.jar test

7. I wrote a little html-file containing the following code:
<html>
<head>
<title>lwjgl test</title>
<meta content="">
<style></style>
</head>

<body>
<applet code="GLApplet" archive="test.jar">
</applet>
</body>
</html>


8. I loaded all the needed Files to my Webspace and tested it, but the error that occured is the one I told you at the beginning of my Post.

I dont know where I made a Mistake, but hopefully someone of you does :)

Unic
Title: Re: Problem with Applet
Post by: kappa on February 01, 2008, 17:57:02
which version of LWJGL are you using?
Title: Re: Problem with Applet
Post by: Unic on February 01, 2008, 18:18:23
I am using version lwjgl-1.1.4

OS: openSUSE 10.3 (linux)
Browser: Firefox, Opera (same error in both browsers), not tested in IE
Title: Re: Problem with Applet
Post by: kappa on February 01, 2008, 18:40:26
that error sounds more like the "lwjgl.jar" is missing and not a problem with the natives, check if you have included that jar.
Title: Re: Problem with Applet
Post by: Unic on February 01, 2008, 18:56:57
Here is a Screenshot of my Jar:

("HAUKE" is the alias of my generated key)

(http://www.bithauer.de/testJar.png)

This is my MANIFEST.MF (signed):
Manifest-Version: 1.0
Class-Path: lib/jinput.jarlib/lwjgl_applet.jarlib/lwjgl_devil.jarlib/l
wjgl_fmod3.jarlib/lwjgl.jarlib/lwjgl_util_applet.jarlib/lwjgl_util.ja
rlib/natives.jarlib/res.jar
Created-By: 1.6.0_03 (Sun Microsystems Inc.)

Name: lib/lwjgl.jar
SHA1-Digest: T8gxnx8pCYC8DAxn8xtB8V8fLqs=

Name: lib/res.jar
SHA1-Digest: 1Zn8+PP8zS0RfM6cjobi8wHiOOs=

Name: unic/GLApplet.class
SHA1-Digest: 8aG9C3A8GE0W99usP7QMAjaA37Q=

Name: lib/lwjgl_fmod3.jar
SHA1-Digest: K4tyUDwt9yiupuklKKoqU4R4fzY=

Name: lib/lwjgl_applet.jar
SHA1-Digest: Ly5CcoZ9G3l+Cn351JLVNEZQMDc=

Name: lib/natives.jar
SHA1-Digest: 7qDxH6hCNPrLieBgDUqRWOBe0o0=

Name: lib/lwjgl_util_applet.jar
SHA1-Digest: +kOnsoqZmC4rd6yskNMXWfEXHWo=

Name: lib/lwjgl_devil.jar
SHA1-Digest: gD9fU4EE4X+1q4pxmEXOpJ9F7Sc=

Name: unic/AppletCanvas.class
SHA1-Digest: +O+/i7MNWMit/1yrRV6UQ5QzcyU=

Name: unic/AppletCanvas$1.class
SHA1-Digest: TAvuFKCzXgg5dleYjIIqoL0vzCY=

Name: lib/lwjgl_util.jar
SHA1-Digest: XgGMYUIZnNGf+MDqKQxt4Wv9OkA=

Name: lib/jinput.jar
SHA1-Digest: /DQc6BS1xMKUtmdcF7ptPVZx/gg=



Title: Re: Problem with Applet
Post by: kappa on February 01, 2008, 19:27:05
LWJGLInstaller was the old method to use LWJGL with applets, it was flawed and had many problems. Also LWJGLInstaller will no longer be part of LWJGL2 and above.

However LWJGL does have a new more better way to do LWJGL Applets, to use this you will need to use AppletLoader.

very easy to get your current application to use it.

1) you no longer need

try {
  LWJGLInstaller.tempInstall();
} catch (Exception le) {
/* handle exception */
}


in your code and can remove it.

2) you will need

lwjgl_util_applet.jar
appletlogo.png
appletprogress.gif

all these come with the lwjgl download

3) you will have to change your html to


<html>
<head>
<title>lwjgl test</title>
<meta content="">
<style></style>
</head>

<body>
<APPLET code="util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="640" height="480">

                 <param name="al_title" value="TEST">
                 <param name="al_main" value="GLApplet">

                         <param name="al_jars" value="test.jar, lwjgl.jar">

                         <param name="al_logo" value="appletlogo.png">
                 <param name="al_progressbar" value="appletprogress.gif">

                         <param name="al_windows" value="windows_natives.jar">
                 <param name="al_linux" value="linux_natives.jar">
                 <param name="al_mac" value="macosx_natives.jar">


               </APPLET>
</body>
</html>   


4) you no longer need to pack the native jars into another jar (which was complex) and can just include them as they come with the lwjgl download.

5) remember to sign your jars.

hope this helps and is easy for you to understand.

Mazon if you see this, I would recommend you update the wiki or at least put a note on that current tutorial about the new AppletLoader.
Title: Re: Problem with Applet
Post by: Unic on February 01, 2008, 19:34:22
Thank you very much for your fast and helpfull answers, the Problem i have with such a Loader is, that up to now I have found no way to bring Parameter to my Applet, because all Parameter are sent to the Loader (I guess).

Apart from that IT WORKS!!!

Does someone know a possibility to redirect parameters to "my" Applet?
Title: Re: Problem with Applet
Post by: kappa on February 01, 2008, 19:36:30
no need to worry, you can just set parameters with the other parameters, and they should pass straight through the loader to your applet.

also just for the record, i should mention that you can also use the version parameter with the AppletLoader.

<param name="al_version" value="0.1">

This is optional but will ensure that your applet is only downloaded once and cached, so you don't have to download the whole applet every time it is run. If you increment the version number then it will redownload the latest applet version. If you just leave out the parameter then it will download the applet every time it is run (good for testing).
Title: Re: Problem with Applet
Post by: Matzon on February 01, 2008, 19:58:21
Quote from: javalwjgl on February 01, 2008, 19:27:05
Mazon if you see this, I would recommend you update the wiki or at least put a note on that current tutorial about the new AppletLoader.
I will - but I'm a bit busy at the moment, hope to be able to do it tomorrow! - thanks for helping him out and describing the steps for the wiki :)
Title: Re: Problem with Applet
Post by: Unic on February 02, 2008, 13:22:14
New day, new problem:

The AppletLoader seems to work... but only in Konqueror  ???

http://www.bithauer.de/lwjgl/app.htm (http://www.bithauer.de/lwjgl/app.htm)

In Firefox I have the Problem, that the AppletLoader doesn't start to load, but I don't know if this is a Problem of Firefox or a Problem of Linux.

In Opera the AppletLoader asks if I want to accept the certificat, then loads all the files and then crashes :(

Maybe anyone of you understands this ErrorLog:

http://www.bithauer.de/hs_err_pid29654.log (http://www.bithauer.de/hs_err_pid29654.log)

I cant find an Error...

It would be great if a few of you would test my Applet (link is at the top of this post) and tell me if the Applet starts (spinning white square on black background) and what Browser you are using.
Title: Re: Problem with Applet
Post by: Matzon on February 02, 2008, 15:18:33
Quote from: Unic on February 02, 2008, 13:22:14
New day, new problem:

The AppletLoader seems to work... but only in Konqueror  ???

http://www.bithauer.de/lwjgl/app.htm (http://www.bithauer.de/lwjgl/app.htm)

In Firefox I have the Problem, that the AppletLoader doesn't start to load, but I don't know if this is a Problem of Firefox or a Problem of Linux.

In Opera the AppletLoader asks if I want to accept the certificat, then loads all the files and then crashes :(

Maybe anyone of you understands this ErrorLog:

http://www.bithauer.de/hs_err_pid29654.log (http://www.bithauer.de/hs_err_pid29654.log)

I cant find an Error...

It would be great if a few of you would test my Applet (link is at the top of this post) and tell me if the Applet starts (spinning white square on black background) and what Browser you are using.
Try Opera 9.5 Alpha.

Firefox + IE + Opera 9.5 all worked fine on Windows XP
Title: Re: Problem with Applet
Post by: kappa on February 02, 2008, 18:55:58
also running SUSE 10.3 works fine here on Firefox 2, Opera 9.5 and Konqueror.

Check that normal applets work in Firefox 2, you may need setup the java applet plugin to work with it properly. (usually done by creating a symlink to javaplugin.so in /usr/lib/browser-plugins).
Title: Re: Problem with Applet
Post by: Nexus on February 08, 2008, 13:13:09
I have a problem running applet with lwjgl. I use version 1.1.4 of the library and do everything as described in the udated wiki entry (http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/applet). Unfortunately, when I open the appletloader.html in browser an error occurs just after "Updating classpath" message is displayed by the loader. I get following error message:
Quote
An error occured while loading the applet.
Please contact support to resolve this issue.
Fatal error occured (7): org.game.Main.

The org.game.Main.java file looks as follows:

package org.game;

import javax.swing.JApplet;
import java.awt.BorderLayout;
import java.awt.Canvas;

public class Main extends JApplet {

    public void init() {
        setLayout(new BorderLayout());
        try {
            Canvas canvas = new AppletCanvas();
            canvas.setSize(getWidth(), getHeight());
            add(canvas);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


AppletCanvas class was pasted from the example added to previous wiki entry on applets and it is included in my jar file as well. Although the error occurs even if the Main class consists only an empty init function.
I'm using Netbeans 6.0 to create jar file and Firefox 2.0 to test the applet.
Title: Re: Problem with Applet
Post by: kappa on February 08, 2008, 13:29:56
get any output on the java console?
Title: Re: Problem with Applet
Post by: Nexus on February 08, 2008, 14:55:17
Hmm... I tried running it with appletviewer - it displays black window with following red text:
QuotePermissions for Applet Refused.
Please accept the permissions dialog to allow
the applet to continue the loading proccess.

On the system console where I start appletviewer I get following message:
QuoteFatal error occured (2): access denied (java.util.PropertyPermission java.io.tmpdir read)
Title: Re: Problem with Applet
Post by: kappa on February 08, 2008, 15:55:46
ah looks like a permissions problem, either you click cancel on the dialog box asking for permissions to run signed applet or you have not signed your jars properly.
Title: Re: Problem with Applet
Post by: Nexus on February 08, 2008, 17:41:39
Quoteyou click cancel on the dialog box asking for permissions to run signed applet
Ther's no dialog box asking about that.

Quoteyou have not signed your jars properly
Hmm... I use keytool to generate key and then jarsigner to sign my jar file the very same way Unic descibed in his first post in this topic. What can I do wrong? I either tried using library jar files signed as they are or signing them on my own with no effect whatsoever...
Title: Re: Problem with Applet
Post by: kappa on February 08, 2008, 18:09:43
hmm strange that there is no dialog box asking for permission, which could be caused by a number of situations.

1. You check the box to always trust that certificate (if so try remove it from the java control panel) which would cause it not to show.

2. You clicked cancel on the dialog at which point the current jvm labels the certificate untrustworthy and won't show up again until a new jvm is started. The current jvm will continue to run until browser is closed and started again (means closing all browser windows).