Applet, JAR, deploying problems

Can some one help me with deploying applet into jar file and embending this jar into html page?



Here's code of my applet:

package jmetest.awt.applet;

import com.jme.bounding.BoundingBox;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.TriMesh;
import com.jme.scene.shape.Box;
import com.jmex.awt.applet.SimpleJMEApplet;

public class AppletTestBoxColor extends SimpleJMEApplet {
    private static final long serialVersionUID = 1L;

    private TriMesh t;
    private Quaternion rotQuat;
    private float angle = 0;
    private Vector3f axis;

    public void simpleAppletUpdate() {
        float tpf = getTimePerFrame();
        if (tpf < 1) {
            angle = angle + (tpf * 35);
            if (angle > 360) {
                angle -= 360;
            }
        }

        rotQuat.fromAngleNormalAxis(angle * FastMath.DEG_TO_RAD, axis);
        t.setLocalRotation(rotQuat);
    }

    public void simpleAppletSetup() {
        getLightState().setEnabled(false);
        rotQuat = new Quaternion();
        axis = new Vector3f(1, 1, 0.5f).normalizeLocal();

        Vector3f max = new Vector3f(5, 5, 5);
        Vector3f min = new Vector3f(-5, -5, -5);

        t = new Box("Box", min, max);
        t.setModelBound(new BoundingBox());
        t.updateModelBound();
        t.setLocalTranslation(new Vector3f(0, 0, -15));
        getRootNode().attachChild(t);

        t.setRandomColors();                 
        getRenderer().setBackgroundColor(ColorRGBA.randomColor());   
    }
}



Jar file is exported from eclipse IDE. It's called "myapplet.jar"
It contains some directories inside:
.jmetestawtapplet
.META-INF

In first directory tree there are two files:
AppletTestBoxColor.class
AppletTestBoxColor.java

In second directory there is only one file:
MANIFEST.MF

Manifest-Version: 1.0
Main-Class: jmetest.awt.applet.AppletTestBoxColor



Here is my html file, I trying to use lwjgl applet loader...

<html>
  <body style="background-color:gray">
  <applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar, lzma.jar, myapplet.jar" codebase="." width="720" height="480">

   <param name="al_title" value="appletloadertest">
    <param name="al_main" value="jmetest.awt.applet.AppletTestBoxColor">
    <param name="al_logo" value="appletlogo.png">
    <param name="al_progressbar" value="appletprogress.gif">
    <param name="al_jars" value="lwjgl_applet.jar.pack.lzma, lwjgl.jar.pack.lzma, jinput.jar.pack.lzma, lwjgl_util.jar.pack.lzma, res.jar.lzma">
    <param name="al_windows" value="windows_natives.jar.lzma">
    <param name="al_linux" value="linux_natives.jar.lzma">
    <param name="al_mac" value="macosx_natives.jar.lzma">
 
  </applet>
  </body>
</html>



When I open this html file in web browser (Firefox or IE8) there's "lwjgl" logo, progress bar... but it hangs on "switching applets"...

Can someone help me with this!?

What does the java console output say?

Can you 'activate' the applet, by clicking into the applet area?



You can try to use the newer kind of lwjgl Applets by extending SimpleApplet (BaseSimpleApplet/BaseApplet) or SimplePassApplet.


I cannot activate applet by clicking on it. It does nothing. Moreover I cannot display Java Console, so I don’t know what’s the problem :frowning:



Core-Dump said:

You can try to use the newer kind of lwjgl Applets by extending SimpleApplet (BaseSimpleApplet/BaseApplet) or SimplePassApplet.


How to do that?

I managed to run Java Console (under Opera) and here it what it says:


Exception in thread "AppletLoader.loaderThread" java.lang.NoClassDefFoundError: com/jmex/awt/applet/SimpleJMEApplet
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   at java.security.SecureClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.defineClass(Unknown Source)
   at java.net.URLClassLoader.access$000(Unknown Source)
   at java.net.URLClassLoader$1.run(Unknown Source)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(Unknown Source)
   at com.opera.AppletClassLoader.findClass(AppletClassLoader.java:352)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at com.opera.AppletClassLoader.loadClass(AppletClassLoader.java:433)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClassInternal(Unknown Source)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Unknown Source)
   at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:696)
   at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:608)
   at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.jmex.awt.applet.SimpleJMEApplet
   at com.opera.AppletClassLoader.findClass(AppletClassLoader.java:369)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at com.opera.AppletClassLoader.loadClass(AppletClassLoader.java:433)
   at java.lang.ClassLoader.loadClass(Unknown Source)
   at java.lang.ClassLoader.loadClassInternal(Unknown Source)
   ... 18 more



How to fix this!?

myapplet.jar and the jme.jar has to be in the al_jars parameter and not in the archive parameter.

Ok. We're almost home. Right now applet starts, but it's… hmmm… blank (white) and Java Console throw exception:


Fatal error occured (8): Error creating input provider
Exception in thread "AWT-EventQueue-1" java.lang.RuntimeException: Error creating input provider
   at com.jme.input.KeyInput.get(KeyInput.java:582)
   at com.jmex.awt.applet.SimpleJMEApplet$2.focusGained(SimpleJMEApplet.java:191)
   at java.awt.Component.processFocusEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
   at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
   at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.SequencedEvent.dispatch(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)
   at java.security.AccessControlContext.checkPermission(Unknown Source)
   at java.security.AccessController.checkPermission(Unknown Source)
   at java.lang.SecurityManager.checkPermission(Unknown Source)
   at java.lang.reflect.AccessibleObject.setAccessible(Unknown Source)
   at com.jme.input.KeyInput.get(KeyInput.java:579)
   ... 19 more

this is a crash in the init() of the jme applet, it looks from the error your trying to access a function which is not allowed by the java sand box, either don't use that or sign the jar that is calling it.



maybe jme.jar is not signed?

Signing the "jme.jar" file worked out! Now the applet works just fine!  :smiley:

JME Applet + JAR = NIGHTMARE!  }:-@

I tried to get a SimpleJMEApplet work in my browser the whole evening and after

Java-Console had quite much to complain about I got the applet start…



BUT nevertheless the canvas in my firefox-browser stayed white…(the application

was running). Don't know why but IE could display it as it should while my firefox cannot. Strange thing…



That is no JME-specific problem. Even the lwjgl-applet-2.1.0 (and the last alpha-version) didn't

work in (my) firefox but in IE. Anyone had the same effect?



EDIT: Also updating to the newest java6 version (14) did't help. My firefox-version at work showed the applet

as it should… maybe I should reinstall firefox or even windows…

do you get any error in the console? does dragging another window over the white applet start it?

My Firefox (3.0.10) display lwjgl applet fine. Isn't the newest version of java 1.6.x ? In my case Opera is the browser which handle java applets better that IE8 and FF3  8)

BadmanPL666 said:

My Firefox (3.0.10) display lwjgl applet fine. Isn't the newest version of java 1.6.x ? In my case Opera is the browser which handle java applets better that IE8 and FF3  8)


opera? out of all the browser in my experience that is the worst browser for java applets. LWJGL applets are pretty broken in opera 10 beta 1.

I've FF3, IE8, O10. And Opera works best with JME/JWJGL applets. Thath's just my opinion. FF3 works worst!

BadmanPL666 said:

Core-Dump said:

You can try to use the newer kind of lwjgl Applets by extending SimpleApplet (BaseSimpleApplet/BaseApplet) or SimplePassApplet.


How to do that?


See here: http://www.jmonkeyengine.com/jmeforum/index.php?topic=10569.0