Can't run applet inside a web page

Hi all,



I am new here, i saw the new .11 version of jmonekeyengine in OpenGl.org and i am making already a web3D project with JME. I have practice with Ogre, so i like so much JME.



I have my application as an applet, i create a Swing application and one of their canvas is a JMECanvasImplementator.



I am using JBuilder 2007, and within jbuilder all is OK, runs fine.

Now i want to be able to run the applet inside a web page, and i cannt.



This is the java console:



java.lang.NoClassDefFoundError: Test3D (wrong name: src/Test3D)

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 sun.applet.AppletClassLoader.findClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.applet.AppletClassLoader.loadClass(Unknown Source)

at java.lang.ClassLoader.loadClass(Unknown Source)

at sun.applet.AppletClassLoader.loadCode(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)





This is the html:



<applet    code="Test3D.class"

archive="engine.jar,nativelibs.jar,test.jar"

width="1024"

height="700">

</applet>





I splited the files into several JARs, (the nativelibs, the JME and dependencies JARs, and my src package)

I have the 3 JARs and the html into the same folder.

And i have unsigned and signed with my key all the JARs.



Can you point me??



Thanks a lot,

Jordi.


Me again…



I decided to don't split the JARs yet, i am using one JAR with all the project.



Now the message i have is the following:



java.lang.NoClassDefFoundError: com/jmex/awt/JMECanvasImplementor

at src.Test3D.<init>(Test3D.java:44)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)



I have not unsigned and signed again the JAR, can be caused for that?



Jordi.

Have you verified that JMECanvasImplementor is in fact in your one JAR?

Yes, it is inside the JAR file, inside jme-awt.jar into a subfolder called JME

the internal folder structure of a jar file has to reflect the package structure.

so if the class is  called com.jmex.awt.JMECanvasImplementor, it should be in the jar in com/jmex/awt

nice! i remade the JAR file keeping the correct structure.



Now the applet runs a bit more but i have this erros on the java console:

I don't know how to tell to the applet or to the JAR the folder where the nativelibs lie, i tryed to copy they into the root of the JAR, and uncompressed with the .html and .jar, but they don't load.





04/05/2007 19:47:04 com.jme.system.lwjgl.LWJGLDisplaySystem <init>

INFO: LWJGL Display System created.

java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

at java.lang.ClassLoader.loadLibrary(Unknown Source)

at java.lang.Runtime.loadLibrary0(Unknown Source)

at java.lang.System.loadLibrary(Unknown Source)

at org.lwjgl.Sys$1.run(Sys.java:75)

at java.security.AccessController.doPrivileged(Native Method)

at org.lwjgl.Sys.doLoadLibrary(Sys.java:68)

at org.lwjgl.Sys.loadLibrary(Sys.java:84)

at org.lwjgl.Sys.<clinit>(Sys.java:101)

at org.lwjgl.opengl.AWTGLCanvas.<clinit>(AWTGLCanvas.java:88)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createCanvas(Unknown Source)

now if you would just try the forum search function or look into the wiki :stuck_out_tongue:

What sfera meant to say was:



http://www.jmonkeyengine.com/wiki/doku.php?id=writing_a_jme_applet



:stuck_out_tongue:

Yes Sfera, learn tact from Gentleman Hal…as long as he's not talking to/about me he generally does quite well.  :stuck_out_tongue:

What the hell you talking about; stupid frog?!

Thanks to all,





I read in one of the posts that LWJGL uncompress natives.jar to a temp directory so that the applet can run, i have my html now:



<applet    code="src.Test3D"

archive="test.jar,natives.jar"

width="1024"

height="700">

</applet>



and i've added the natives.jar to the root folder containing OpenAL32.dll, lwjgl.dll, lwjgl-fmod3.dll, jinput-raw.dll, jinput-dx8.dll



But the problem persisits.



Executing in the command line i could especify the java.library.path manually, but in an applet form i have not idea; the DLLs are correct cause i run fine within JBuilder.



Thanks.

Here's the tag I use to show one of our test applets in a web page:



<applet code="jmetest.awt.applet.AppletTestBoxColor" archive="lwjgl_util_applet.jar,lwjgl.jar,jme.jar,jme-awt.jar,jme-test.jar,natives.jar" width="800" height="600">

</applet>



Try with these jars specified as above.

No way.



My html, as you says: (the JARs are in his place all signed with the same key)



<applet code="src.Mobles3D"

archive="natives.jar,source.jar,lwjgl_util_applet.jar,lwjgl.jar,jme.jar,jme-awt.jar,jme-test.jar"

width="800"

height="600">

</applet>



The java console: (in firefox)



05/05/2007 19:27:22 com.jme.system.lwjgl.LWJGLDisplaySystem <init>

INFO: LWJGL Display System created.

java.lang.NoClassDefFoundError: Could not initialize class com.jmex.awt.lwjgl.LWJGLCanvas

at com.jme.system.lwjgl.LWJGLDisplaySystem.createCanvas(Unknown Source)

at src.SwingFrame.initialize(SwingFrame.java:134)

at src.SwingFrame.<init>(SwingFrame.java:71)

at src.Mobles3D.<init>(Mobles3D.java:44)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)





the java console ( in internet explorer)



05/05/2007 19:30:39 com.jme.input.joystick.DummyJoystickInput <init>

INFO: Joystick support is disabled

05/05/2007 19:30:39 com.jme.system.lwjgl.LWJGLDisplaySystem <init>

INFO: LWJGL Display System created.

java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path

at java.lang.ClassLoader.loadLibrary(Unknown Source)

at java.lang.Runtime.loadLibrary0(Unknown Source)

at java.lang.System.loadLibrary(Unknown Source)

at org.lwjgl.Sys$1.run(Sys.java:75)

at java.security.AccessController.doPrivileged(Native Method)

at org.lwjgl.Sys.doLoadLibrary(Sys.java:68)

at org.lwjgl.Sys.loadLibrary(Sys.java:84)

at org.lwjgl.Sys.<clinit>(Sys.java:101)

at org.lwjgl.opengl.AWTGLCanvas.<clinit>(AWTGLCanvas.java:88)

at com.jme.system.lwjgl.LWJGLDisplaySystem.createCanvas(Unknown Source)

at src.SwingFrame.initialize(SwingFrame.java:134)

at src.SwingFrame.<init>(SwingFrame.java:71)

at src.Mobles3D.<init>(Mobles3D.java:44)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at java.lang.Class.newInstance0(Unknown Source)

at java.lang.Class.newInstance(Unknown Source)

at sun.applet.AppletPanel.createApplet(Unknown Source)

at sun.plugin.AppletViewer.createApplet(Unknown Source)

at sun.applet.AppletPanel.runLoader(Unknown Source)

at sun.applet.AppletPanel.run(Unknown Source)

at java.lang.Thread.run(Unknown Source)



The contents of natives.jar:

      OpenAL32.dll

      lwjgl.dll

      lwjgl-fmod3.dll

      jinput-raw.dll

      jinput-dx8.dll





I think all is correct, perhaps the natives.jar is not what should be, I don't know.


The fact that you get two completely different errors says to me that you either have a cache issue or there is something really odd with your jars.  It really should be that hard to set up the applet.  We do it all the time at work and it functions fine on both firefox and ie.

Thanks renanse,



Do you think is possible that i can send to you my project? i have only the skeleton of the application, only an OBJ in the screen, perhaps you could see the odd thing easily.

In that moment i can't continue with my application if I cannt emmed it on an applet inside a web page, so that i would be very agreed with that.



Jordi.

Sure, although you'll need to be patient if I don't get to it right away because of JavaOne.

Oops guys…!



I think i had basic mistakes:


  • I was building my app from the JMESwingTest demo, as i need the Swing controls and the 3D canvas.
  • In the class SwingFrame of the demo, i extend from JApplet, not JFrame, cause i need the app to be an applet.



    I supose there is no way with the JApplet, i must use SimpleJMEApplet, and i need to use JMEDesktop to add the SwingControls.





    Is that correct?

SimpleJMEApplet is simply a class making it easier to write your own applet.  You can have a look at what it does and mimic it in your own applet class.  As for desktop though, I've heard here on the forums that getting it to function in an applet is difficult or maybe not possible currently?

UUUhh!!!



I've rewritten my app to be build on top of SimpleJMEApplet, now i have the applet running in my IDE and also from web server, cool!



I plan to rebuild the user interface with BUI…



Would be good for next releases to draw a plan to be able to use Swing controls embended on an applet, just a suggestion.



thanks,

Jordi.

I worked more in my app, i acomplished to add the swing controls on top if my simpleJMEApplet, as easy as use simpleJMEApplet.add(component) method an insert JPanels with buttons, etc… runs smoothly, great.