WoSGamers

WoSGamers welcome you again, the view faces, pleasing your body - thanking!

I am trying to compile to a JAR the attached files to run in a web browser, i believe i have the HTML code correct, comparing it to others. However i am getting these errors when running it in the webpage:

oad: class MazeApplet.class not found.
java.lang.ClassNotFoundException: MazeApplet.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.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$AppletExecutionRunnable.run
(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: Z:\Documents\Uni Work
\09.10\Advanced Web Games Development\Week 2\MazeApplet\class.class
(The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.(Unknown Source)
at java.io.FileInputStream.(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown
Source)
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: MazeApplet.class
MazeApplet::init() called
java.security.AccessControlException: access denied
(java.io.FilePermission wall.png 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.checkRead(Unknown Source)
at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
at sun.awt.SunToolkit.getImage(Unknown Source)
at javax.swing.ImageIcon.(Unknown Source)
at javax.swing.ImageIcon.(Unknown Source)
at MazeApplet.init(MazeApplet.java:91)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run
(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.security.AccessControlException: access denied
(java.io.FilePermission wall.png read)
MazeApplet::start() called
MazeApplet::run() called

Can anyone shed any light onto why the file does not run, attached is a zip of the source and some additional files needed for the class

Cheers
Jossy

AWGD_Maze.zip

Share 

Add a Comment

You need to be a member of WoSGamers to add comments!

Join this social network

Kalakian Comment by Kalakian on October 14, 2009 at 3:45pm
That should be the game engine now fixed as well, which is handy since I'll be introducing it tomorrow. Thanks for highlighting that error before anybody started using it :)

The sorted function in the game engine is:

static public Image loadImage(String filename)
{
Toolkit tool = Toolkit.getDefaultToolkit();
URL url = GameApplet.getInstance().getClass().getResource(filename);
Image img = tool.getImage(url);
MediaTracker mTracker = new MediaTracker(GameApplet.getInstance());
mTracker.addImage(img,1);
try
{
mTracker.waitForID(1);
}
catch (InterruptedException e)
{
e.printStackTrace();
}

return img;
}

But when passing a path, you must make sure to preceed it with a forward slash '/' so it knows to look for the image relative to the root of the jar, which is important if your code is split into packages. That's why it wasn't working for the engine at first, because it was looking for the image relative to the current class file inside a package structure.

So the code you need to allow images to be loaded from inside the jar file, whether using packages or not would be:

tool.getImage(getClass().getResource("/wall.png"));
Jossy Barron Comment by Jossy Barron on October 14, 2009 at 3:44pm
and thats it :) well done deryk
Kalakian Comment by Kalakian on October 14, 2009 at 2:34pm
Ok, I think I've found the source of your problem, and it appears the same problem exists in the game engine. Typical, I have created jar files with sprite loading, tested them, and everything is fine, but when I implemented image loading in the game engine I have only tested it from inside eclipse :/

Quick fix for you should be to use

tool.getImage(getClass().getResource("wall.png"));
instead of
tool.getImage("wall.png");

which basically looks for the png file relative to the class file (i.e. inside the jar). I'll need to fix the game engine as this doesn't actually work because it looks for resources relative to the game engine class files rather than the game code class files. That's my problem though, let me know if your applet now works.
Jossy Barron Comment by Jossy Barron on October 14, 2009 at 1:49pm
yey, new set of issues, seems to be recognising the class file now, what would cause this error?:

Reading certificates from 11 http://jossyb2000.googlepages.com/AWGDMaze.jar | C:\Documents and Settings\B00105397\Application Data\Sun\Java\Deployment\cache\6.0\45\1069fc6d-16d22ca9.idx
MazeApplet::init() called
java.security.AccessControlException: access denied (java.io.FilePermission wall.png 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.checkRead(Unknown Source)
at sun.awt.SunToolkit.getImageFromHash(Unknown Source)
at sun.awt.SunToolkit.getImage(Unknown Source)
at MazeApplet.init(MazeApplet.java:92)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Exception: java.security.AccessControlException: access denied (java.io.FilePermission wall.png read)
MazeApplet::start() called
MazeApplet::run() called

most recent JAR file attached - not protected
AWGDMaze.jar
Ross Forshaw Comment by Ross Forshaw on October 13, 2009 at 11:21am
The method I posted above does not require the images to be stored in the .jar file. Though when passing file paths to it, it is best to make them relative.
Jossy Barron Comment by Jossy Barron on October 13, 2009 at 9:13am
right i think i know what one of the problems is but dont know how t fix it, i changed the image method over so that should be fine, reading up online it seems that eclipse doesnt export all the libs u need or rather running within eclipse is fine but without it needs addditional libs added, i jus dont know how to do that.

I google part of this error and discovered this:

Projects must be referenced by an EAR or a WAR to use classpath publish/export dependencies whose runtime path (../) maps into the parent component.

any ideas?
Kalakian Comment by Kalakian on October 13, 2009 at 7:12am
Ah, but have you uploaded the class files for your game or is it packaged in a jar file? That's the method he was already using and was getting an error for.
Ross Forshaw Comment by Ross Forshaw on October 13, 2009 at 1:34am
This setup is guaranteed to work on the Internet as I used it for my Asteroid game.

import java.awt.* ;
import java.awt.geom.* ;
import java.awt.event.* ;
import java.net.* ;

public class Sprite()
{
Image img ;
Sprite( String path )
{
java.net.URL imageURL = Main.class.getResource( path ) ;
this.img = new javax.swing.ImageIcon( imageURL ).getImage() ;
}
}

And that is pretty much it when it comes to loading Images for Web games. :)
Jossy Barron Comment by Jossy Barron on October 12, 2009 at 11:01pm
thanks :)
Kalakian Comment by Kalakian on October 12, 2009 at 8:25pm
Just noticed you had attached your source code, and you are using the swing method of loading images. Try the method I posted above and you should be fine.

About

John Sutherland John Sutherland created this social network on Ning.

Music

Loading…

Poll


Santa's coming, lock up your daughters!
What do you want the fat old man with the fake beard to bring you for Christmas? (you can choose as many as you want!)
Final Fantasy XIII
Nintendo DS LL
Super Street Fighter IV
Sony PSP Go Black
MAG: Massive Action
Xbox 360 with Free60 preloaded
God of War III
Super Mario Bros. Wii
Nintendo Wii Black
Battlefield: Bad Company 2
Pandora Open Source console
Rogue Warrior
Sony PS3 Slim 250Gb
Bayonetta
Apple iPod touch
Resident Evil: Darkside
to pass Computer Systems
Gran Turismo 5


Forum

Steven Logan

Do we need to come into uni this week at all? 2 Replies

Started by Steven Logan in Teaching & Learning @UWS. Last reply by Daniel Livingstone 5 hours ago.

Euan "YONS" Hislop

Christmas and new year lab times 2 Replies

Started by Euan "YONS" Hislop in Teaching & Learning @UWS. Last reply by Nicola Gallacher 8 hours ago.

Kalakian

Intro to Games Dev - Games 22 Replies

Started by Kalakian in Teaching & Learning @UWS. Last reply by Daniel Livingstone 13 hours ago.

Thee Forsaken One

Decent Screen Recorders 6 Replies

Started by Thee Forsaken One in Tech Chat. Last reply by Jonathan Traynor 1 day ago.

Tam

Rage Against X Factor 3 Replies

Started by Tam in News. Last reply by Gary Hogg 1 day ago.

Jon Robertson

Final Fantasy XIII 10 Replies

Started by Jon Robertson in Just for fun. Last reply by Kazzie Dec 18.

Kazzie

Final Fantasy FXIV beta testing applications 5 Replies

Started by Kazzie in Just for fun. Last reply by Kazzie Dec 18.

Phil McCauley

GameSpot's Best of 2009!

Started by Phil McCauley in Just for fun Dec 18.

Daniel Livingstone

PhD opportunities

Started by Daniel Livingstone in Portfolios & Employment Dec 16.

Michael "Bez" Berryman

Stupid Answers 3 Replies

Started by Michael "Bez" Berryman in Just for fun. Last reply by Prof. Dr. SatNAV MSc CGT DDR FF7 Dec 16.

Kieran Nelson

Realtime Worlds Student Programming Contest 5 Replies

Started by Kieran Nelson in Teaching & Learning @UWS. Last reply by Ross Forshaw Dec 16.

Jeremy Koester

Looking for programming support 2 Replies

Started by Jeremy Koester in Portfolios & Employment. Last reply by Jeremy Koester Dec 16.

Daniel Livingstone

CGD Project: Design and Plan

Started by Daniel Livingstone in Teaching & Learning @UWS Dec 15.

Stevo aka Dr Katata Fish

John Sutherland 69 Replies

Started by Stevo aka Dr Katata Fish in News. Last reply by Stevo aka Dr Katata Fish Dec 15.

Stevo aka Dr Katata Fish

SAAS 6 Replies

Started by Stevo aka Dr Katata Fish in News. Last reply by Jon Robertson Dec 11.

David McClure

Multimedia Fusion 2 Discounts 1 Reply

Started by David McClure in News. Last reply by Kieran Nelson Dec 9.

Tam

Evony Web advert evolution 5 Replies

Started by Tam in Just for fun. Last reply by John Sutherland Dec 9.

Peter Bloomfield

My new favourite puzzle game

Started by Peter Bloomfield in Just for fun Dec 8.

John Sutherland

Dare to Be Digital 32 Replies

Started by John Sutherland in Projects. Last reply by John Sutherland Dec 8.

Badge

Loading…

© 2009   Created by John Sutherland on Ning.   Create Your Own Social Network

Badges  |  Report an Issue  |  Privacy  |  Terms of Service

Sign in to chat!