Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Deploying LWJGL applet problems  (Read 2113 times)
0 Members and 1 Guest are viewing this topic.
Offline Huw
« Posted 2012-10-11 20:49:25 »

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)

My html file looks like this:

Quote
<applet code="org.lwjgl.util.applet.AppletLoader"
        archive="lwjgl_util_applet.jar"
        codebase="."
        width="800" height="600">
 
  <param name="al_title" value="Targets">
  <param name="al_main" value="org.newdawn.slick.AppletGameContainer">
  <param name="game" value="javagame.Game">
 
  <param name="al_jars" value="Targets.jar, lwjgl.jar, slick.jar, lwjgl_util_applet.jar">
 
  <param name="al_windows" value="windows.jar">
  <param name="al_linux" value="linux.jar">
  <param name="al_mac" value="macosx.jar">
 
  <param name="separate_jvm" value="true">
</applet>


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

I'm a java noob, but I'm learning. My little blog. My Games.
Offline ra4king

JGO Kernel


Medals: 350
Projects: 3
Exp: 5 years


I'm the King!


« Reply #1 - Posted 2012-10-11 20:56:48 »

You included the wrong jars. LWJGL provides signed jars for applets. It's called "lwjgl_applet-<VERSION>.zip" and they are under the "basic" folder.

Offline Huw
« Reply #2 - Posted 2012-10-11 21:01:14 »

You included the wrong jars. LWJGL provides signed jars for applets. It's called "lwjgl_applet-<VERSION>.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)

Also my main class:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
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();
       }
     
     
     
   }
}

I'm a java noob, but I'm learning. My little blog. My Games.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #3 - Posted 2012-10-11 21:17:56 »

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.
Offline Huw
« Reply #4 - Posted 2012-10-11 21:26:43 »

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")

I'm a java noob, but I'm learning. My little blog. My Games.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #5 - Posted 2012-10-11 21:32:02 »

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.
Offline Huw
« Reply #6 - Posted 2012-10-11 21:39:28 »

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!

I'm a java noob, but I'm learning. My little blog. My Games.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!