Deploying LWJGL applet problems

Hi, I’m trying to deploy my java game as an applet and the screen just says the following:

‘Permissions for Applet refused.
Please accept the permissions dialog to allow
the applet to continue the loading process.’

I’m receiving the following errors in the java console:

[quote]This occurred while ‘Determining packages to load’
access denied (“java.util.PropertyPermission” “deployment.user.cachedir” “read”)
java.security.AccessControlException: access denied (“java.util.PropertyPermission” “deployment.user.cachedir” “read”)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
at java.lang.System.getProperty(Unknown Source)
at org.lwjgl.util.applet.AppletLoader.getLWJGLCacheDir(AppletLoader.java:1064)
at org.lwjgl.util.applet.AppletLoader$3.run(AppletLoader.java:1050)
at org.lwjgl.util.applet.AppletLoader$3.run(AppletLoader.java:1038)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.util.applet.AppletLoader.getCacheDirectory(AppletLoader.java:1038)
at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:843)
at java.lang.Thread.run(Unknown Source)
[/quote]
My html file looks like this:

[quote]

[/quote] Any help on what to do would be much appreciated as I'm new to lwjgl applets etc.

You included the wrong jars. LWJGL provides signed jars for applets. It’s called “lwjgl_applet-.zip” and they are under the “basic” folder.

Thankyou, this has gotten rid of those errors, but now it’s still not working, but I think it has something to do with my class and appletgamecontainer, can I still have AppGameContainer in my main class or do I need to change it, since some tutorials weren’t saying to change it?

Console:

[quote]Thu Oct 11 22:07:12 BST 2012 ERROR:javagame.Game
java.lang.InstantiationException: javagame.Game
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.newdawn.slick.AppletGameContainer.init(AppletGameContainer.java:124)
at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:1326)
at org.lwjgl.util.applet.AppletLoader$2.run(AppletLoader.java:909)
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$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$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 java.awt.EventDispatchThread.run(Unknown Source)
This occurred while ‘Initializing real applet’
Unable to create game container
java.lang.RuntimeException: Unable to create game container
at org.newdawn.slick.AppletGameContainer.init(AppletGameContainer.java:148)
at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:1326)
at org.lwjgl.util.applet.AppletLoader$2.run(AppletLoader.java:909)
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$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$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 java.awt.EventDispatchThread.run(Unknown Source)
[/quote]
Also my main class:

package javagame;

import org.newdawn.slick.*;
import org.newdawn.slick.state.*;
/**
 * To-Do List:
 * 
 * Add life losses
 * Add disappearing target timing
 * Add more upgrades
 * Add more levels
 * Add different difficulties
 * Have better drawn graphics
 * Implement working sound
 */
public class Game extends StateBasedGame{
 
	public static final int menu = 0;
	public static final int level1 = 1;
	public static final int shop = 2;
	public static final int gameOver = 3;
	
	public static final String gamename = "Shooting";
	public static int ammo = 5;
	public static int maxlives = 3;
	public static boolean autoreload = false;
	public static String chosensight = "res/sights/sight1.png";
	public static int hiscore1=100;
	public static int hiscore2=75;
	public static int hiscore3=50;
	public static int hhiscore1=100;
	public static int hhiscore2=75;
	public static int hhiscore3=50;
	
	public static int level = 1;
	
	public static int sight2unlock = 0;
	public static int sight3unlock = 0;
	public static int sight4unlock = 0;
	public static int sight5unlock = 0;
	
 
	public Game (String gamename){
		super(gamename);
		this.addState(new Menu(menu));
		this.addState(new Level1(level1));
		this.addState(new Shop(shop));
		this.addState(new GameOver(gameOver));
		
	}
 
	public void initStatesList(GameContainer gc) throws SlickException {
		this.getState(menu).init(gc, this);
		this.getState(level1).init(gc, this);
		this.getState(shop).init(gc,  this);
		this.getState(gameOver).init(gc,  this);
		
		this.enterState(menu);
		
		
	}
 
	
	public static void main(String[] args) throws SlickException {
		try 
	    { 
	      AppGameContainer app = new AppGameContainer( new Game(gamename) );
	      app.setDisplayMode( 800, 600, false );
	      app.start(); 
	    } 
	    catch ( SlickException e ) 
	    { 
	      e.printStackTrace(); 
	    } 
		
		
		
	}
}

Make sure your javagame.Game class doesn’t use any parameters in its constructor method (i.e. it should be in the format “public Game()” ), otherwise Slick’s AppletGameContainer can’t create a new instance of it.

So get rid of “String gamename”, you can just hard code it inside the Game contructor method if you want to set a gamename instead of passing one to it.

Thanks! It’s now loading, except it can’t get access to my resources, hopefully I can figure this out myself…

Start of console:
Thu Oct 11 22:30:13 BST 2012 ERROR:access denied (“java.io.FilePermission” “.\res\title.png” “read”)
java.security.AccessControlException: access denied (“java.io.FilePermission” “.\res\title.png” “read”)

You can’t use File to access resources from inside jar files (since they are not on the file system anymore but inside a zip file). So you need to use an InputStream to access them.

I just put my resources folder inside the jar and it’s working fine now, I’ll probably use InputStream as it’ll save hassle/problems in the future, but for now I’m going to bed since I’ve got school tomorrow:( Thanks for all the help!