java.security.AccessControlException: access denied

Started by AGP, June 16, 2009, 01:11:06 AM

Previous topic - Next topic

AGP

This error is produced by manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResource("RacerModels/Textures"), "jaguarsk.jpg")); but not by background = new javax.swing.ImageIcon(this.getClass().getResource("RacerModels/Textures/CLOUDS1.JPG")).getImage();

The same error is true for manager.add(String, new Texture(this.getClass().getResourceAsStream(...)). What gives?

paulscode

Quote from: AGP on June 16, 2009, 01:11:06 AM
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResource("RacerModels/Textures"), "jaguarsk.jpg"));
Probably just a typo, but I noticed you didn't include an actual filename:
manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResourceAsStream("RacerModels/Textures/JAGUARSK.JPG"), "jaguarsk.jpg"));

AGP

It's neither a typo nor the only way I tried it. This: manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getResourceAsStream("RacerModels/Textures/jaguarsk.jpg"))); doesn't work either (same security error).

EgonOlsen

Could be because the Swing-stuff is signed by SUN already (or trusted by default) and the methods that i'm using for loading a texture aren't. But i can't use any other to stay compatible with 1.1. You may try to load the images yourself and use the appropriate constructor that takes an image.

AGP

That did the trick. So simple! Still, I wish it had worked. What is the purpose of 1.1 compatibility, anyway?

EgonOlsen

Quote from: AGP on June 16, 2009, 08:59:19 AM
That did the trick. So simple! Still, I wish it had worked. What is the purpose of 1.1 compatibility, anyway?
The purpose is...being compatible with 1.1... ;D Some users still rely on this.

EgonOlsen

Apart from that: If the files are in the jar, the applet should be able to access them no matter what.

AGP

But it wasn't able until I loaded them through ImageIcon. I can't explain it either. Anyway, as long as it works I am happy. I will post you a link of that racing game you liked soon. At this point I'm just working out the collision-detection. And here's a question: invisibility won't affect collision-detection, will it (I thought once that it did but I hope I'm wrong)?

Oh, and I was going to write that I think the latest version of Firefox changed the way it handles its cache, because all of a sudden I can run, change, recompile, repackage, and run again without it giving me headaches, which is making it much easier on me to test my stuff.

EgonOlsen

Visibility DOES affect collision detection. You can't collide with something that isn't visible/active. If this is a problem, set all colliders to visible before calling the collision methods and reset them afterwards where needed. I'm always doing it this way, because i usually use completely different meshes for collision than i use for the visuals.

paulscode

Oh, I think I know what the problem might have been.  Rather than calling getResource[AsStream]() directly from Class, try using getClassLoader().getResource[AsStream]() instead:

manager.addTexture("jaguarsk.jpg", new Texture(this.getClass().getClassLoader().getResourceAsStream("RacerModels/Textures/jaguarsk.jpg"), "jaguarsk.jpg"));

AGP

Thanks for the suggestion, paulscode. Is your way any faster?

And Egon, how fast is it to make something visible/invisble? Because as I understand, I'm going to have to make my object visible, test for collision, then make it invisible before I draw for every iteration. So is it just flipping an internal boolean or does work get done?

EgonOlsen

Nope, it's just flipping a boolean. As said, i'm doing this constantly.

AGP

Egon, I really hate showing my stuff to people because I really hate criticism, but here it goes: http://www.agpgames.com

All but the starship game is working to the point of showing it (if maybe not yet bragging!). Check out the racer. And by the way, I didn't do collision between the two cars yet. Thanks a whole lot both to you and to paulscode for the help with the opponent car. Street Fighter was a family joke between me, my wife my brother-in-law and his girlfriend (now wife). I'm still going to add blood and black eyes. All games are meant for an analog joystick, even if they work (badly) with the keyboard.

EgonOlsen

#13
My analog joystick (i've actually never really used it before) seems to suck. When plugged in and calibrated, the screen in Racer spins and doesn't stop. So i tried to play with the keyboard, which works pretty bad...as you've "promised".

I think Racer is a really good start. I like how it looks so far. Here are my suggestions on how to improve it IMHO:


  • Scale your textures to power of 2. jPCT does this for you while loading, but it slows down the loading process
  • Get rid of the double loading of textures. For some reason, you seem to load them twice
  • Fix the transparency. Remember that even the software renderer can do additive blending, which should look nice on the lights
  • Improve the keyboards controls. I have to hit UP multiple times to accelerate, which is very annoying
  • Fix the steering. It seems to rotate the car even when standing still
  • Somehow, the size of the car doesn't really match the rest of the scene. The car is hardly higher than the curb and maybe half as high as a door. That looks pretty strange. Like in some AAA commercial shooter games, where your hero barely reaches the doorknob... ;D
  • Add support for the hardware renderer. You are loading LWJGL anyway, so why not use it to fullest if possible!? Albeit i like the look of the software renderer...
  • Consider to use raft's MipMapping extension when using the software renderer (if the applet's memory restrictions allow for that)

As said, it's a good start. I think that improving the controls is the most important part because the best game concept fails if the controls suck. I'll try to find one of my semi-analog Competition Pro USB joysticks to see, if they work better....

Keep up the good work!

BTW: I can't load the street fighter applet...the link seems to be wrong.


Edit: Found and tried the Competition Pro...it's better than the other joystick but not much better than the keyboard. How am i supposed to accelerate? No matter what i do, i'm driving very very slow. This is on a P4M @ 2.2Ghz, i.e. a pretty old laptop of mine.



paulscode

Quote from: AGP on June 16, 2009, 06:17:15 PMThanks for the suggestion, paulscode. Is your way any faster?
I don't know, but it should eliminate the access control exception problem you were having when loading stuff that is compiled inside the JAR.