How to run your Slick2D game as applet

Monday, March 04, 2013 , , , 3 Comments

In order to run your jar file as applet you need to sign it first or you have to use policy but signing jar file is more practicle than using policy so you will need to learn how to sign your jar file with your own digital sign.

Download lwjgl applet package [Link] which comes with signed jars it also contains example :)

After buiding your game goto 'dist' folder ( i am using netbeans ) and copy your game's jar file and then open it with any archive program (winrar,7zip etc) and add your 'data' folder in it which contains all the images,sounds etc to game's jar file.then sign the jar with this method : Link

Now make one folder named applet and put game and all the libraries your game uses in that folder.Make game.html and put applet code in it and execute. If everything is went well then it will run your game in browser. :)

Sample HTML file : http://pastebin.com/HY2Mxh9n

Just a note, my game requires mysql connector and i needed to sign mysql jar and then add it to the 'al_jars' param of the html applet code then it worked fine.

Some Tips :

1) Check that your game is not using System.Exit() in any ways.

2) Move game's frame-rate code to init method because applet does not call the main() of main class.

3) You can enable java console to view exception stack from
control-panel -> java -> goto advanced tab in 'java console' select 'show console' and press ok.

4) If signing jar is not working then first make a file named java.policy.applet in your applet folder with following code
grant { permission java.security.AllPermission; };
after saving it open cmd and goto applet folder through cmd
and then run following command
appletviewer -J-Djava.security.policy=java.policy.applet your-applet.html

Have Fun :D !!

3 comments:

  1. Really it will be helpful for these Visual dot coding.I want to work out this coding for my visual in windows amazing working and it answers come correct. I will refer my friends.
    Selenium Training in Chennai

    ReplyDelete
  2. Wonderful blog. Thanks for sharing..
    The role of software testing is a process which should be complete understanding for the successful implementation, execution and running of a software product and it's basically classified into manual testing and automation testing using software testing tools.

    ReplyDelete
  3. Franchise Opportunities@ https://franolaxy.com
    Franchise opportunities in India@ https://franolaxy.com
    Franchise Opportunities India@ https://franolaxy.com
    Brand Establishment@ https://franolaxy.com

    ReplyDelete