Applet generator

very important for me is one method of distribution directly to the web, because I want to dedicate to the casual games on the web.



there any comprehensive tutorial and running through ditribucion applets.



I found one with JME3 but does not work. and now that I think I've never seen a program in jme running directly in the browser.



any ideas or suggestions?

Not right now, applet support is coming but you can use WebStart, it allows starting the software from the browser like here: http://jmonkeyengine.com/webstart/q3test/



Cheers,

Normen

yes, I use Java WebStart http://www.unocol.com/jj/launch.html.



if for the moment no other way I would like to let me know when this is possible

montblack said:

I've never seen a program in jme running directly in the browser.


This is jME 2 though.. But it's perfectly possible.

http://www.calefay.com/site/play-applet

(not my work btw!)

- Mikkel
montblack said:

very important for me is one method of distribution directly to the web, because I want to dedicate to the casual games on the web.

there any comprehensive tutorial and running through ditribucion applets.

I found one with JME3 but does not work. and now that I think I've never seen a program in jme running directly in the browser.

any ideas or suggestions?


I did a successful test. Here's the how-to.

IDE Netbeans 6.8 (you can also do it by hand but it's easier with the ide).

Dowload latest JME3 zip (jME3_06-03-2010.zip), extract it somewhere
New Project -> Java Application, name "JME3AppletTest"
In the Projects tab, right click "Libraries" -> Add Jar/Folder -> select all the jar files of JME3

Change the Main class in:

package jme3applettest;

import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import java.awt.Canvas;
import javax.swing.JApplet;

public class Main extends JApplet {

    private Application app;
    private Canvas canvas;
    private JmeCanvasContext context;

    @Override
    public void init() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                AppSettings settings = new AppSettings(true);
                settings.setWidth(800);
                settings.setHeight(600);
                settings.setUseInput(false);
                app = new SimpleApplication() {

                    @Override
                    public void simpleInitApp() {
                    }
                };
                app.setSettings(settings);
                app.createCanvas();
                context = (JmeCanvasContext) app.getContext();
                canvas = context.getCanvas();
                canvas.setSize(settings.getWidth(), settings.getHeight());
                add(canvas);
            }
        });
    }

    @Override
    public void start() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                app.startCanvas();
            }
        });
    }

    @Override
    public void stop() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                app.stop();
            }
        });
    }

    @Override
    public void destroy() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                remove(canvas);
                app.destroy();
            }
        });
    }
}



Menu "Run" -> "Set Project Configuration" -> "Customize"
Select "Web Start" on the left side, check "enable web start", Codebase "User Defined" (leave blank the Codebase preview field), check "self signed" - >ok

Clean and build. The IDE will sign the jar files with a test certificate and prepare everything for the deployment.

Now open the "dist" directory of the netbeans project (with explorer), there is a "launch.html" file, open that with the browser. After a while you will see the applet up and running.

package jme3applettest;

import com.jme3.app.Application;
import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import java.awt.Canvas;
import javax.swing.JApplet;

public class Main extends JApplet {

    private Application app;
    private Canvas canvas;
    private JmeCanvasContext context;

    @Override
    public void init() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                AppSettings settings = new AppSettings(true);
                settings.setWidth(800);
                settings.setHeight(600);
                settings.setUseInput(false);
                app = new SimpleApplication() {

                    @Override
                    public void simpleInitApp() {
                    }
                };
                app.setSettings(settings);
                app.createCanvas();
                context = (JmeCanvasContext) app.getContext();
                canvas = context.getCanvas();
                canvas.setSize(settings.getWidth(), settings.getHeight());
                add(canvas);
            }
        });
    }

    @Override
    public void start() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                app.startCanvas();
            }
        });
    }

    @Override
    public void stop() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                app.stop();
            }
        });
    }

    @Override
    public void destroy() {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                remove(canvas);
                app.destroy();
            }
        });
    }
}



on firefox= open but doesnt work this error

[spanish]
java.io.FileNotFoundException: C:Program FilesMozilla Firefoxlwjgl.dll (Acceso denegado)
[english]
java.io.FileNotFoundException: C:Program FilesMozilla Firefoxlwjgl.dll (access denied)

on chrome = not open, don't  work

on applet safary= not open, dont work

on internet explorer = works great! (cause its a .dll the lwjgl)

so, I think the problem is the Lightweight Java Game Library (lwjgl).
may need to be compiled into the jar or some other alternative.

more suggestions or opinions?

The problem arises when the java vm in the browser is run on another thread. Disable "run java in own thread" in the java-settings on osx, then it should work in safari.

There are more problems with the applets like hijacked mouse etc. as said, it will be coming so please be patient and check back on the site for more info.

The chrome-safari issue maybe due to the lack of the java plug-in. What I find interesting is the firefox message. Why is it trying to load libraries from that folder?



I have deployed the proposed applet in a test page (8 mb more or less)



http://www.tukano.it/test/jme3/launch.html



This works on Ubuntu 32, Firefox with sun-jre-6 plugin. The log (read through the java console) says that the folder where native libraries are extracted is my home folder (INFO Natives 17.09.58 Extraction Directory #3: /home/pgi). What happens if you try it with firefox?

If running in applet or webstart you must call JmeSystem.setLowPermissions(true) before you do anything. Otherwise it will try to extract the natives which won't work.

For an applet example, check the applet folder in SVN. It uses LWJGL's AppletLoader to properly load natives and uses Sun's deployJava script to load it, the class AppletHarness is invoked to make any applet specific initialization. This way you can load ANY jME3 program that properly extends the "Application" like the tests for example.

I want to use jme3,I want join this group ,thanks.