Being like Minecraft (or how to run your libgdx app in web browser)

What's libgdx? It's a game/application development framework in Java. It allows you to write an app, and then run it on Android, on desktop and in the browser. Awesome! If you want to know more, read what its creators say about it.
In this tutorial I'll show you how to run a game written with libgdx in your browser (as a Java applet). So why Minecraft, you might ask - well, Minecraft runs as an applet! (and it's written with Lwjgl - more on that later) And talking about Minecraft is so snazzy these times, you know.
I'm going to use libgdx's "Hello world" as an example "game". I won't cover setting up the project here, Mario (father of libgdx) did it already here.

You should start with something like that:

For applet we'll need to use Lwjgl backend (instead of default Jogl). Don't worry, just one change is required. Edit the file and make it look like that:
 1 2 3 4 5 6 7 8 910
package com.badlogic.gdx.helloworld;
//import com.badlogic.gdx.backends.jogl.JoglApplication;
import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
public class HelloWorldDesktop {
public static void main (String[] argv) {
new LwjglApplication(new HelloWorld(), "Hello World", 480, 320, false);
Now you're using Lwjgl as your backend! All the cool kids use it, so you can consider yourself as cool too. Cool, eh?
Next step: add a new file called (in the same directory as other source files). It's similar to what we had before:
 1 2 3 4 5 6 7 8 910111213
package com.badlogic.gdx.helloworld;
import com.badlogic.gdx.backends.lwjgl.LwjglApplet;
public class HelloWorldApplet extends LwjglApplet
private static final long serialVersionUID = 1L;
public HelloWorldApplet()
super(new HelloWorld(), false);

Create a directory called applet in your project dir. It will contain all files needed to run your game through a browser. Put the following files in there:
  • gdx.jar
  • gdx-backend-lwjgl.jar
  • gdx-backend-lwjgl-natives.jar
  • gdx-natives.jar
You can copy them from your libgdx distribution. But that's not all! You will need a few more files:
  • lwjgl_util_applet.jar - this is the actual applet launcher. The Lwjgl guys made a sophisticated tool for that. It is configurable via an html file, which we will add in a moment. Get this launcher by downloading the latest Lwjgl distribution. It's 2.7.1 as I write it. Copy lwjgl-2.7.1/jar/lwjgl_util_applet.jar to your applet dir.
  • helloworld.jar - this is your game. Just export the whole project as jar in Eclipse:
    You can click "Finish" in this window.
  • index.html - this is the actual page that your browser will open. You should set some options for lwjgl_util_applet.jar here. I'm using these:
     1 2 3 4 5 6 7 8 910111213141516171819202122232425262728293031323334353637
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <div id="applet_container">
    <applet code="org.lwjgl.util.applet.AppletLoader" archive="lwjgl_util_applet.jar" codebase="." width="800" height="480">
    <param name="al_title" value="HelloApplet">
    <param name="al_main" value="com.badlogic.gdx.helloworld.HelloWorldApplet">
    <param name="al_logo" value="appletlogo.png">
    <param name="al_progressbar" value="appletprogress.gif">
    <param name="al_bgcolor" value="000000">
    <param name="al_fgcolor" value="ffffff">
    <param name="al_jars" value="helloworld.jar, gdx.jar, gdx-backend-lwjgl.jar">
    <param name="al_windows" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
    <param name="al_linux" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
    <param name="al_mac" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
    <param name="al_solaris" value="gdx-natives.jar, gdx-backend-lwjgl-natives.jar">
    <param name="codebase_lookup" value="false">
    <param name="java_arguments" value="-Dsun.java2d.noddraw=true -Dsun.awt.noerasebackground=true -Dsun.java2d.d3d=false -Dsun.java2d.opengl=false -Dsun.java2d.pmoffscreen=false -Xmx800M">
    <param name="lwjgl_arguments" value="-Dorg.lwjgl.input.Mouse.allowNegativeMouseCoords=true">
    <param name="separate_jvm" value="true">
    <param name="codebase_lookup" value="false">
    All the options are documented here.
Now we've got everything we need! Open index.html with your browser and... it won't work. Why?
By default applets are allowed to use a restricted subset of Java. This is not enough for libgdx/lwjgl, so you need to sign ALL jars in the applet dir. It can be done by standard JDK tools (they may be not in your path though). First, create a keystore with one key. Run the following command in the applet dir:
keytool -genkey -alias gdxkey -keypass gdxpassword -validity 360 -keystore .keystore
This command will create a .keystore file, which will contain a single key named "gdxkey". I recommend setting the keystore password the same as your key password ("gdxpassword" in this case).
Now you can (and should) sign all jars. I'm using the following batchfile for that (copy the code and save it as sign-applets.bat in the applet dir):
@for /f %%i in ("%0") do @set curpath=%%~dpi
@cd /d %curpath%
@for /r . %%X in (*.jar) do jarsigner -keystore .keystore -storepass gdxpassword %%X gdxkey
Of course this will work for Windows users only. Linux users are capable enough to write a bash script or anything similar, and Mac users... well, sorry. :)
After signing the jars fire up index.html again. Answer some security question and enjoy libgdx in your browser!

I know it looks pretty complicated, but one you've set it all up, releasing a new applet version of your game is easy:
  1. Export .jar containing your game
  2. Sign this jar
If you're smart, you can write an Ant script for that. Obviously I am smart, but I'm also too lazy to do that.

The last step: show me your game! You need to upload everything except .keystore and sign-applets.bat (so basically all jars and index.html) to some web server and give me the link! :)
I recommend Amazon S3 for hosting purposes (I'm using it for Pixel Slaughter!, Minecraft's using it too), but you can even publish it in your Dropbox. I did this too with my example project.

58 Response to "Being like Minecraft (or how to run your libgdx app in web browser)"

  1. Unknown says:

    Creating an applet version of my game was on my list, so you've saved me quite a bit of work figuring it out. Thanks.


    Anonimowy says:

    nice post, just a quick note as your using lwjgl 2.7.1 the

    < param name="al_errorcolor" value="ff0000">

    is no longer used.

    Thotep says:

    Fixed it, thanks.

    Thanks for posting this, I never made an applet before and wanted to share my libgdx project with some friends online.

    Kubecz3k says:

    Thanks for great article. I will certainly make a good use of it :)

    Now my project runs on my phone and in a browser. Thanks!

    Thotep says:

    Glad it worked! Where's the link then? ;)

    Anonimowy says:

    Nice to hear this is working. May I request a jogl version, or why a jogl version is hard / not possible? Thanks!

    Thotep says:

    Currently you can do libgdx-powered applets only through lwjgl.

    Thank you! It work!

    evan says:

    it's still giving me a class not found exception, and i followed this tutorial to the tee. any suggestions?

    Thotep says:

    At which point do you get this exception? Please provide full stacktrace.

    Anonimowy says:

    When I tried this, I got this message.

    An error occurred while loading the applet
    This occurred while 'Switching applet'

    How can I troubleshoot to find out what is causing the error?


    Thotep says:

    Enable Java console in your browser to get the full error message and a stacktrace.

    Ashiq says:

    I'm getting an invalid SHA1 hash exception for AppLoader.class$2. Any ideas?

    java.lang.SecurityException: invalid SHA1 signature file digest for org/lwjgl/util/applet/AppletLoader$2.class
    at Source)
    at Source)
    at Source)
    at java.util.jar.JarVerifier.processEntry(Unknown Source)
    at java.util.jar.JarVerifier.update(Unknown Source)
    at java.util.jar.JarFile.initializeVerifier(Unknown Source)
    at java.util.jar.JarFile.ensureInitialization(Unknown Source)
    at java.util.jar.JarFile.getCodeSources(Unknown Source)
    at java.util.jar.JavaUtilJarAccessImpl.getCodeSources(Unknown Source)
    at com.sun.deploy.cache.DeployCacheJarAccessImpl.getCodeSources(Unknown Source)
    at$ParentCallback.openClassPathElement(Unknown Source)
    at$JarLoader.getJarFile(Unknown Source)
    at$JarLoader.access$800(Unknown Source)
    at$JarLoader$ Source)
    at Method)
    at$JarLoader.ensureOpen(Unknown Source)
    at$JarLoader.(Unknown Source)
    at$ Source)
    at Method)
    at Source)
    at Source)
    at Source)
    at sun.plugin2.applet.Plugin2ClassLoader$ Source)
    at Method)
    at sun.plugin2.applet.Plugin2ClassLoader.findClassHelper(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
    at sun.plugin2.applet.Plugin2Manager$ Source)
    at Source)
    Exception: java.lang.SecurityException: invalid SHA1 signature file digest for org/lwjgl/util/applet/AppletLoader$2.class

    Thotep says:

    Did you put the AppletLoader jar inside the jar you exported from your project? Don't do that, they must be separate.

    Ashiq says:

    @Thotep nope, I didn't do that.

    Anonimowy says:

    I get an error while "Extracting downloaded packages", how can I debug this?

    Thotep says:

    Turn on the Java Console.

    Anonimowy says:

    Ok, the error that I'm getting is:

    The certificate(s) in gdx-natives.jar do not match the AppletLoader!
    java.lang.Exception: The certificate(s) in gdx-natives.jar do not match the AppletLoader!
    at org.lwjgl.util.applet.AppletLoader.extractNatives(

    Thotep says:

    You didn't sign it properly. All jars need to be signed with your certificate AND NO OTHER.

    Anonimowy says:

    I get the same exception for gdx-natives.jar - how is it possible that all the other jars get signed correctly and this doesn't?

    Thotep says:

    Go inside every .jar file (they're juest regular zip files) and remove the dir META-INF (if it exists). This will remove all signatures (including yours). Then sign them all again with your certificate.

    Anonimowy says:

    I had spaces in the path to my applet dir, so the batch file failed for me. Putting the %%X in the batch file in quotes fixes that :)

    Anonimowy says:

    I cannot play my test project, and your example project has the same error. Any ideas?

    basic: Plugin2ClassLoader.getPermissions CeilingPolicy allPerms
    java.lang.Exception: JNLPClassLoaderUtil: couldn't find a valid JNLPClassLoaderIf
    at com.sun.jnlp.JNLPClassLoaderUtil.getInstance(Unknown Source)
    at com.sun.jnlp.JnlpLookupStub.findService(Unknown Source)
    at com.sun.jnlp.JnlpLookupStub.access$000(Unknown Source)
    at com.sun.jnlp.JnlpLookupStub$ Source)
    at Method)
    at com.sun.jnlp.JnlpLookupStub.lookup(Unknown Source)
    at javax.jnlp.ServiceManager.lookup(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.badlogic.gdx.backends.lwjgl.LwjglNativesLoader.(
    at com.badlogic.gdx.backends.lwjgl.LwjglApplet.(
    at com.badlogic.gdx.helloworld.HelloWorldApplet.(
    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 org.lwjgl.util.applet.AppletLoader.switchApplet(
    at org.lwjgl.util.applet.AppletLoader$
    at java.awt.event.InvocationEvent.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 Source)
    Exception in thread "LWJGL Application" com.badlogic.gdx.utils.GdxRuntimeException: org.lwjgl.LWJGLException: Pixel format not accelerated
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.access$0(
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$
    Caused by: org.lwjgl.LWJGLException: Pixel format not accelerated
    at org.lwjgl.opengl.WindowsPeerInfo.nChoosePixelFormat(Native Method)
    at org.lwjgl.opengl.WindowsPeerInfo.choosePixelFormat(
    at org.lwjgl.opengl.WindowsDisplay.createWindow(
    at org.lwjgl.opengl.Display.createWindow(
    at org.lwjgl.opengl.Display.create(
    at org.lwjgl.opengl.Display.create(
    at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(
    ... 2 more

    Anonimowy says:

    Great tutorial, helped me to port Space Squad ( Libgdx is amazing.

    Jyro117 says:

    I was trying to figure out the best way to deploy a test version. I came across this post which was pretty clear to follow. After a few personal tweeks I will respect your request to view the game!

    Jacco says:

    Thanks for this post! I'm having some trouble running the applet though, I think it has to do with the .jar that should contain the game.

    I'm using the setup as described here: . So basically there are seperate projects for the (core) game and its targets. For now I've added both the core project and the desktop project (which also contains the applet code) to the jar.

    The LWJGL-applet will start but hangs while "validating: gdx-backend-lwjgl.jar". Any help would be appreciated.

    Thotep says:

    Please read the comments above, the first thing you need to do is to check the exact error message in Java console.

    Unknown says:

    This post is a life saver! I am having trouble getting it to work though. My applet keeps crashing with this error:

    This occurred while 'Switching applet'
    Couldn't load shared library 'gdx.dll' for target: Windows 7, 32-bit
    com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load shared library 'gdx.dll' for target: Windows 7, 32-bit
    at com.badlogic.gdx.utils.SharedLibraryLoader.load(
    at com.badlogic.gdx.utils.GdxNativesLoader.load(
    at com.badlogic.gdx.backends.lwjgl.LwjglNativesLoader.load(
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.(
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.(
    at com.badlogic.gdx.backends.lwjgl.LwjglApplet$LwjglAppletApplication.(
    at com.badlogic.gdx.backends.lwjgl.LwjglApplet$2.addNotify(
    at java.awt.Container.addNotify(Unknown Source)
    at java.awt.Panel.addNotify(Unknown Source)
    at java.awt.Container.addImpl(Unknown Source)
    at java.awt.Container.add(Unknown Source)
    at org.lwjgl.util.applet.AppletLoader.switchApplet(
    at org.lwjgl.util.applet.AppletLoader$
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$ Source)
    at java.awt.EventQueue$ Source)
    at Method)
    at$1.doIntersectionPrivilege(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 Source)
    Caused by: java.lang.NullPointerException
    at com.badlogic.gdx.utils.SharedLibraryLoader.load(
    ... 26 more

    Any ideas? I would greatly appreciate it!

    Thotep says:

    Looks like you forgot to include gdx-natives.

    Unknown says:

    Where exactly do I need to include it? I have it in the index.html as well as in the applet folder. I built the project in the included project generator and am working in eclipse.

    Unknown says:

    Hi, I also deveklope fr java,... Java is a very easy to use language once u get a hold of it.... if
    anyone is a beginner in java then they should attend some interesting java
    focused conferences which gives a huge knowledge abt the language nd very
    interesting, easy tips nd tricks which are very useful... few of the famous
    java conferences are Javapolis (devox), JavaOne, and recently i received a mail
    from oracle regarding their JavaOne conference..They have many interesting sessions lined up fr this year... you can take a look at their sessions related topics here:

    I myself hoping to attend several sessions about Core Java Platform; JavaFX, Java
    Embedded, and Java Card and many more.

    I guess m sharing it here coz It’s the best place to learn about what’s new
    and what’s next, see the latest from Oracle and our partners, connect with
    peers, and meet with experts...
    There are many topics covering Java SE,
    JavaFX, also few sessions on building mobile and embedded Java applications
    targeting next-generation smart devices.. Java EE–based enterprise solutions

    Developing with the latest Oracle database
    technology, business applications in the cloud securely..

    Hope u enjoy

    Jacco says:
    Ten komentarz został usunięty przez autora.
    Anonimowy says:

    JAR manifest application-library-allowable-codebase mismatch for

    Nice blog. Thanks for sharing. See also this website about mspy phone tracker.

    Read also
    Watch Live Online Free
    How To Watch Live TV Online - Download Live TV APK
    How To Verify PayPal Without Bank Account
    QueenCee VPN V5 Lite APK Free Download
    Best Credit Card For Online Shopping
    Track any Person Mobile Number anywhare by Mobile number or CNIC Download This Amazing App Instant Person Tracker

    Learn Complete How To Earn $500 Per Month By Mobile & Computer at home.

    Unknown says:

    nice and good work show now
    driveragent plus product key

    SHINA LEY says:

    Spyhunter 5 crack

    sifu12 says:

    Internet Download Manager Serial Number 100 percent free Download is the majority of a good system that we are able to make use of to download document in conjunction with as many as five events pace. IDM Crack Pro License Key Zero cost Download is awesome because it will accelerate your download speeds incredibly quite simply, unbelievably useful if your web website link rates of pace usually

    If You are looking for something different, then I am ready. Russian Escorts in Goa I am well educated, have an open mind and have the girlish charm that Is fun and easy to be found. You will always find me smart, clean and fresh as I am very conscientious about my hygiene and I expect all my clients to reciprocate in the same manner. Check our other Services...
    Russian Escorts in Goa
    Russian Escorts in Gurgaon
    Russian Escorts in Gurgaon
    Russian Escorts in Gurgaon
    Russian Escorts in Gurgaon
    Russian Escorts in Haridwar

    niced work MiniTool Partition Wizard Crack is the best software

    wondershare mobiletrans is the best software i love it

    Hi! This is my first visit to your blog! We are a group of volunteers and starting a new initiative in a community in the same niche. Your blog provided us beneficial information to work on. You have done a extraordinary job!MiniTool Partition Wizard Crack Pro 12 & Serial Key 2020 Torrent

    So nice I am enjoying for that post as for u latest version of this Security tool Available…MiniTool Partition Wizard Technician Crack 12 With Serial Key Latest 2020

    Adobe Fresco Crack introduces a revolutionary new real-time brush to ensure a completely natural painting experience. For artists, illustrators, designers and animation creators as well as anyone who wants to discover or rediscover the joy of painting and drawing. Use watercolors and oils that can bloom and mix when touched, use vector brushes and raster pencils together on the same canvas, and choose your favorites from the thousands of resources provided by Photoshop and renowned master Kyle T. Webster. Adobe Fresco 2020 gives you the largest selection and the world's most unique selection. You can customize the UI to make drawing with your right or left hand easier, and switch to full-screen mode to avoid distractions on the canvas.

    Riya Sen says:

    We have a List of Girls who are in financial problems. They need your help. They are ready to sleep with you in some small amounts. Call us for their contact no and help them. To book an escort just drop a call to the given number and ask them what kind of service you want!. You will also WhatsApp us for the availability of ourEscorts Service in Lucknow. If you’re in the end determined and ready to enjoy the amusing of being at duration the corporate of one of our beautiful girls. Check our other Services...
    Female escort In Lucknow
    Foreigner Escorts in Lucknow
    Independent Call Girls in Lucknow
    Model Call Girls in Lucknow
    Russian Call Girls Lucknow
    Russian Escorts in Lucknow

    I really found what I was for thanks very much. I will check another post for a helpful info thanks

    thank you so much...this information was really helpful. In case you are searching for Office 2010 Toolkit & EZ Activator you can get it from for free.

    Iftalia says:

    This is what I was finding. Thank you for sharing.

    simon le says:

    wow!!!thanks for sharing this blog

    Iftalia says:

    Great article!
    Thanks for sharing!
    Hey! here is the link of New Designing Software:
    Download it in Free & Enjoy!

    HK Crack says:

    is a data backup program for all Windows and Mac computers. It is a great software for recovering data lost or deleted for any reason. This software allows the user to access information such as images, videos, contact slide shows, records, messages, location information, and stored information from each application.

    waqas66 says:

    Easy Video Logo Remover Crack is the software that allows you to remove logos, titles and watermarks. You can say that it is a simple tool which can enhance your photos in video files by removing subtitles, signatures and logos. Easy Video Logo Remover is the easiest and most user-friendly way to remove the logo. This tool is very small and light, you can download it for free. You can do it all with just a few clicks. You need to load the video file into the program first and then choose the location where the logo will appear. You can preview the video images by moving the play slider to the desired time. This action allows you to identify the marker you want to remove from the image Crackcook.

    Hasleo Data Recovery Crack
    PDF Password Remover Crack
    Smallpdf Crack
    UltraISO Crack
    LUXONIX Purity Crack
    FabFilter Crack
    Miroslav Philharmonik 2 VST Crack
    EZkeys Crack Mac
    I am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me

    Iftalia says:

    Hi there, I found your site via Google at the
    same time as looking for a comparable matter, your website came up, it
    seems to be good. I’ve bookmarked it in my google bookmarks.
    Here is the link of Artweaver Plus Free Download:
    It’s a complete painting tool with a huge collection of descriptive realistic brushes that allow you to paint and experiment creatively.

    shoaib says:

    I also love the theme/design, I don’t have time to go through it all at the moment but I have
    saved it and also added your RSS feeds, so when I have
    the time I will be back to read a lot more, Please do keep
    up the awesome work.
    ant download manager crack
    agisoft photoscan crack
    ivi crack
    cubase pro crack

Publikowanie komentarza

Powered by Blogger