Problem with Applet

Started by Unic, February 01, 2008, 15:32:26

Previous topic - Next topic

Unic

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 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

kappa

which version of LWJGL are you using?

Unic

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

kappa

that error sounds more like the "lwjgl.jar" is missing and not a problem with the natives, check if you have included that jar.

Unic

Here is a Screenshot of my Jar:

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



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=



kappa

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.

Unic

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?

kappa

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).

Matzon

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 :)

Unic

New day, new problem:

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

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

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.

Matzon

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

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

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

kappa

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).

Nexus

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. 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.

kappa

get any output on the java console?

Nexus

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)