jME application as an applet


Has anyone succeed to run jME applicaion in an applet?

I tried 3 approaches:


but application can't see native libraries which are in linux_natives.jar


using LWJGL AppletLoader

I've got hangs described above:

but rewriting SimpleJMEApplet to SimpleApplet doesn't help


using Applet-launcher

My applet can't validate native libraries.

Can you give me a link to the working example?

I haven't got any experience with jME in applets, but have you considered using Java Web Start(JLNPs) instead?

Yes, but I would like to embed my application in HTML site.

matt_z said:

Yes, but I would like to embed my application in HTML site.

i found but it runs with jME3. Is there a similar example with jME 2?

That URL doesn’t seem to exist anymore. Is there an example for this?

I have an app that extends SimpleBulletApplication, which extends Application, and I want to make an applet out of it.

Theres an example class in the jme3test directory.

I remember there was alot of trouble for me getting jme2 running as an applet, although i managed in the end. I’ll see if i can dig something up this weekend.


I’m just now getting back to working on my project.

I looked at the LWJGL site for some of their examples, and it appears as though they don’t have any tutorials on how to launch an applet from Eclipse. I still get this error:

Exception in thread "Thread-4" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path at java.lang.ClassLoader.loadLibrary( at java.lang.Runtime.loadLibrary0( at java.lang.System.loadLibrary( at org.lwjgl.Sys$ at Method) at org.lwjgl.Sys.doLoadLibrary( at org.lwjgl.Sys.loadLibrary( at org.lwjgl.Sys.( at org.lwjgl.opengl.Display.( at RunApplet2$
With this code:
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import com.jme3.system.JmeSystem;
import java.applet.Applet;
import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.BorderLayout;
import java.util.concurrent.Callable;
import javax.swing.SwingUtilities;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;

public class RunApplet extends Applet {
private static JmeCanvasContext context;
private static Application app;
Canvas canvas;
private static RunApplet applet;
Thread gameThread;

public RunApplet(){

public void createCanvas(String appClass){
AppSettings settings = new AppSettings(true);
try {
Class<? extends Application> clazz = (Class<? extends Application>) Class.forName(appClass);
app = clazz.newInstance();
}catch (ClassNotFoundException ex){
}catch (InstantiationException ex){
}catch (IllegalAccessException ex){
context = (JmeCanvasContext) app.getContext();
canvas = context.getCanvas();
canvas.setSize(settings.getWidth(), settings.getHeight());
public void startApp(){
app.enqueue(new Callable() {
public Void call(){
if (app instanceof SimpleApplication){
SimpleApplication simpleApp = (SimpleApplication) app;
return null;
public void freezeApp() {
public void unfreezeApp() {
public final void update(Graphics g){
public void init(){
applet = this;
public void start(){
// context.setAutoFlushFrames(true);
public void stop(){
// context.setAutoFlushFrames(false);
public void destroy(){
SwingUtilities.invokeLater(new Runnable(){
public void run(){



If you run the applet in eclipse the natives won’t be loaded because it is not using LWJGL AppletLoader.

In the createCanvas() method, you can remove the line




when testing in eclipse, and put it back again when using AppletLoader. It should then load the natives.

So, I need to use the LWJGL applet loader in Eclipse, but when I deploy, I need to remove the LWJGL applet loader?

No, when you run from eclipse, you’re not using the LWJGL AppletLoader. When you deploy, you have to use AppletLoader because thats the only way of loading the natives in a limited-permissions environment.

Ah, okay.

So, my original problem still stands that I can’t get an applet to run launched from Eclipse. I believe my pasted code above is exactly like what’s in the test class.

So check the Eclipse manual?

I had a similar problem in netbeans. It came down to the natives. If it’s the same problem i had, you need to: unpack the lwjgl native files into a folder. Put that folder on the classpath of the project as a virtual machine option (in netbeans: -Djava.library.path=“path”). It may or may not be necessary, but my project shows the path to “lwjgl” as well. ( I tried alot of things).

On a side note; using the win 64 natives that came with the latest downloaded package from lwjgl did not work, and gave me an exception (related to “getPointer”) when launching. Unpacking the natives in the jme bundle worked, however.

The exception was the same as is documented here: .

michalk said:
Ah, okay.
So, my original problem still stands that I can't get an applet to run launched from Eclipse. I believe my pasted code above is exactly like what's in the test class.

You can run applets from eclipse, you just need to make sure the environment is setup correctly. That is all required jars are on the classpath and any native files that are used are extracted somewhere and pointed to.

how to basically setup lwjgl to work

1. Right Click you project and select properties.
2. Click 'Java Build Path' and choose the 'Libraries' Tab.
3. Add lwjgl.jar here, once its there, click the little arrow next to lwjgl.jar to bring drop down.
4. Click 'Native Library Location' to set it to point to the folder that contains the lwjgl native files.
5. add any other external jars your using here (jme.jar, etc).

Thats it, now you should be able to run jME applets by just running your games main applet class.

My post still stands …

If you remove the line




Then it should run in eclipse. Did you try that?

I teach Java programming class and I wrote an educational 3d engine running on top of jME2 ( Since the focus of Env3D is education, I tried to make it absolutely easy to perform certain tasks – make 3D applet is one of them.

I was successful in 3D applet creation using the appletloader approach in LWJGL. Since my class is taught using the BlueJ IDE, I wrote a BlueJ plug-in to automate the process. All my students need to do is press a button in the IDE and an applet is generated for them.

Here is an example of the applet in action running as a facebook application (

You can checkout my code on the sourceforge svn to see how it is done. The class to look at is EnvApplet.

Hope this helps.

1 Like