Results 1 to 20 of 37
- 01-16-2011, 08:23 PM #1
Member
- Join Date
- Jan 2011
- Posts
- 1
- Rep Power
- 0
Java Applet Strange Image Loading Problem
Hi, I'm having a problem with loading images in a Java Applet. This problem is very unusual and I think i know what the problem is but I don't know how to fix it. I made an applet (game) that requires access to several GIF image files for the menu, sprites, etc. When I am running this game on a local machine (not through a server) the game works fine, all images loads and it has no lag. However when I upload this game onto a remote server and try to run it through a webpage, only some images load while others are missing.
Thru trial and error I found that if I didn't load some of the bigger images (by bigger i mean images that take up more room on a hard drive), all the other images would load, however as soon as I included the code to load these bigger images again, certain images go missing. It seems like I am only allotted a certain amount of space on the user's hard drive or memory and the biggest problem is my largest images are only about 70kbs, with the total size of all my images being 600kB. I don't think this is a large size and I'm wondering if theres anyway to change the quota on a client's computer so that all images can load.
Additional info:
-All images are placed in the same location and are all gifs
-I devised a way to tell which images loaded and which didnt, each time the game runs, the same images do not load
-In the coding, I placed the image loading order from loading the largest image to the smallest image however it appears that some of the larger images load and some of the smallers images load, order of loading images didnt seem to affect anything.
-I am using a signed appletLast edited by 1yuchen; 01-16-2011 at 08:27 PM.
- 01-17-2011, 06:07 AM #2
Member
- Join Date
- Dec 2010
- Posts
- 6
- Rep Power
- 0
How to write an applet in netbeans?My purpose is how to open netbeans for applet?
thanks
- 01-17-2011, 06:08 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 6
- Rep Power
- 0
please guide me?
- 12-30-2011, 02:04 PM #4
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
Can anyone help with this? I know this is an old thread but I'm having the exact same problem and it's driving me up the wall!
My applet is also a game and on most computers it runs fine, but on a few sometimes it won't load at all and sometimes it will take about ten minutes to load and when it does some of the larger images are missing. From the server access log I can see that sometimes it requests the main class and gets a 401 and stops. Sometimes it gets a 200 and then stops and others it will get all the necessary files bit by bit (very slowly) and eventually load with the missing images (always the same ones).
Thanks in advance.
- 12-30-2011, 04:06 PM #5
Re: Java Applet Strange Image Loading Problem
Is this a server/browser configuration problem?
Are there any error messages in the browser's java console?
Is the applet code working when you execute it from local files on your PC?
- 12-30-2011, 05:57 PM #6
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
Hi, thanks for your reply. It always works on the server computer and most computers I have tried on my local network and on the internet. There just seem to be the odd few where this problem comes up. Using the same browser and the same version of java. There is normally nothing in the java console (I have a feeling I saw something there once).
I'm not 100% sure what you mean by server/browser configuration. I'm using the latest version of firefox and haven't changed the configuration on either computer, even so if you could point me in the right direction I'll check the configuration.
- 12-30-2011, 05:59 PM #7
Re: Java Applet Strange Image Loading Problem
What is different about the PCs and browsers where the applet has problems?
- 12-30-2011, 06:07 PM #8
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
I can't find any difference! I have to say I'm fairly new to this so I may have missed something glaringly obvious. I have two computers here that I'm testing on and both have the same version of firefox and java. I've tried turning the firewall off on the one causing the problem and it makes no difference. The strange thing to me is that sometimes it will load if you leave it long enough, sometimes it will just ask the server for the main class and then just sit there without making any more requests, whether or not it successfully downloads the main class.
- 12-30-2011, 06:10 PM #9
Re: Java Applet Strange Image Loading Problem
I don't know how the java code can cause it to work differently on different PCs
Try adding some printlns to the code to show the execution progress and maybe where the code is hanging.
- 12-30-2011, 06:20 PM #10
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
My suspicion is that it's not the code. There's a println on line 3 and it doesn't get that far. It doesn't download all the classes and images I assume it should download them before it runs the code?
- 12-30-2011, 06:22 PM #11
Re: Java Applet Strange Image Loading Problem
If there are no errors in the java console, I have no idea what is wrong.
- 01-03-2012, 01:31 PM #12
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
I'm starting to suspect that it has something to do with my html code calling the applet, which is as follows:
<applet
codebase="classes"
code="game/main.class"
width="890" height="450" align="left"
>
</applet>
or my directory structure (which has come from netbeans), note "NetBeansProjects" is the documentroot for my server:
The HTML file is in
NetBeansProjects\game\build
And the class files are here
NetBeansProjects\game\build\classes\game\main.clas s
The reason I think this is that when I try moving the html file to the same folder as the class files, removing the codebase attribute and changing the code attribute I can't load it on any computer and I get similar errors to the ones I am seeing when it will only work on some. It will just load the main class for example and then stop without making any more requests to the server.
- 01-03-2012, 01:45 PM #13
Re: Java Applet Strange Image Loading Problem
Is the main class in a package? If so, you will have to move the main.class file to the folder(s) matching the package.when I try moving the html file to the same folder as the class files, removing the codebase attribute and changing the code attribute I can't load it
Add some println statements to see what statement the execution stops at.It will just load the main class for example and then stop
Do all of the catch{} blocks have calls to printStackTrace()?
- 01-03-2012, 01:48 PM #14
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
I also just found this in the Apache error log. It was logged exactly 5 minutes after the computer on which I can't load the applet apparently successfully loaded the main.class.
File does not exist: C:/Users/User/Documents/NetBeansProjects/game/build/classes/game/main
Shouldn't it be requesting main.class and not just main?
- 01-03-2012, 01:52 PM #15
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
The last folder "game" is the package, the main.class file is already in there.Is the main class in a package? If so, you will have to move the main.class file to the folder(s) matching the package.
Sorry, that may have been misleading, I should have said that the main class downloads from the server. It does not execute, the java console is empty. I assume that the browser should download all classes before it starts to execute the main class?Add some println statements to see what statement the execution stops at.
Do all of the catch{} blocks have calls to printStackTrace()?
- 01-03-2012, 01:55 PM #16
Re: Java Applet Strange Image Loading Problem
By "package" I mean is there a package statement in the main.java source file?
If the main class is in the package game, then the main.class file needs to be in the game folder and the code=game.main
Are any of the java classes you are using in packages? Have package statements in the source?
- 01-03-2012, 02:01 PM #17
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
Sorry for the misunderstanding. I'm quite new to this. There is a statement at the top of the main.java when I open it in netbeans:
package Game;
So in my html file I should have "code=game.main" and not "code=game/main.class"?
As for the rest of the classes, they are all in the game.java file in netbeans, the only package statement is at the top of it.
- 01-03-2012, 02:24 PM #18
Re: Java Applet Strange Image Loading Problem
Java is case sensitive. With "package Game" then: code=Game.main
and the folder name would need to be Game not game.
Then all of the .class files generated when game.java is compiled would have to be in the folder with the same name as the package.the rest of the classes, they are all in the game.java file in netbeans, the only package statement
- 01-03-2012, 02:40 PM #19
Member
- Join Date
- Feb 2011
- Posts
- 58
- Rep Power
- 0
Re: Java Applet Strange Image Loading Problem
Sorry, it's "package game;" and the folder is "game" with lower case. All the .class files are in the same folder. I just tried it with "code=game.main" and it loaded but with the largest images missing. I've seen this before though so it may have nothing to do with the change in the html file. This is what I found in the apache access log:
Note that there are 5 minutes between the first download of the main.class and the next. Sometimes it will wait five minutes and then fail, others it seems to wait 5 minutes and then load but with images missing. This is an abridged version of the log, there are more classes and images. You can see the images which don't load in the middle. All the images are in the same folder. It seems strange to me that all the classes load twice but perhaps that is normal.192.168.1.10 - - [03/Jan/2012:14:12:25 +0100] "GET /game/build/classes/game/main.class HTTP/1.1" 401 401
192.168.1.10 - Rob [03/Jan/2012:14:12:30 +0100] "GET /game/build/classes/game/main.class HTTP/1.1" 200 110009
192.168.1.10 - Rob [03/Jan/2012:14:12:30 +0100] "GET /game/build/classes/game/main.class HTTP/1.1" 200 110009
192.168.1.10 - Rob [03/Jan/2012:14:17:30 +0100] "GET /game/build/classes/game/main.class HTTP/1.1" 200 110009
192.168.1.10 - Rob [03/Jan/2012:14:17:30 +0100] "GET /game/build/classes/game/main.class HTTP/1.1" 200 110009
192.168.1.10 - Rob [03/Jan/2012:14:17:31 +0100] "GET /game/build/classes/game/InterfacePanel.class HTTP/1.1" 200 1795
192.168.1.10 - Rob [03/Jan/2012:14:17:31 +0100] "GET /game/build/classes/game/InterfacePanel.class HTTP/1.1" 200 1795
192.168.1.10 - Rob [03/Jan/2012:14:17:31 +0100] "GET /game/build/classes/game/ShadowPiece.class HTTP/1.1" 200 6914
192.168.1.10 - Rob [03/Jan/2012:14:17:31 +0100] "GET /game/build/classes/game/ShadowPiece.class HTTP/1.1" 200 6914
192.168.1.10 - Rob [03/Jan/2012:14:17:31 +0100] "GET /game/build/classes/game/Spinner.class HTTP/1.1" 200 2737
192.168.1.10 - Rob [03/Jan/2012:14:17:31 +0100] "GET /game/build/classes/game/Spinner.class HTTP/1.1" 200 2737
192.168.1.10 - - [03/Jan/2012:14:17:36 +0100] "GET /game/build/padmainnew.gif HTTP/1.1" 401 401
192.168.1.10 - - [03/Jan/2012:14:17:36 +0100] "GET /game/build/clothTrim.jpg HTTP/1.1" 401 401
192.168.1.10 - - [03/Jan/2012:14:17:36 +0100] "GET /game/build/boardBase12.gif HTTP/1.1" 401 401
192.168.1.10 - - [03/Jan/2012:14:17:36 +0100] "GET /game/build/LOGOmini.gif HTTP/1.1" 401 401
192.168.1.10 - Rob [03/Jan/2012:14:17:36 +0100] "GET /game/build/padmainnew.gif HTTP/1.1" 304 -
192.168.1.10 - Rob [03/Jan/2012:14:17:36 +0100] "GET /game/build/boardBase12.gif HTTP/1.1" 304 -
192.168.1.10 - Rob [03/Jan/2012:14:17:36 +0100] "GET /game/build/classes/game/SliderBlock.class HTTP/1.1" 200 4736
192.168.1.10 - Rob [03/Jan/2012:14:17:36 +0100] "GET /game/build/LOGOmini.gif HTTP/1.1" 304 -
192.168.1.10 - Rob [03/Jan/2012:14:17:36 +0100] "GET /game/build/classes/game/SliderBlock.class HTTP/1.1" 200 4736
192.168.1.10 - Rob [03/Jan/2012:14:17:36 +0100] "GET /game/build/rack.gif HTTP/1.1" 304 -
192.168.1.10 - Rob [03/Jan/2012:14:17:36 +0100] "GET /game/build/classes/game/SliderUp.class HTTP/1.1" 200 3876
- 01-03-2012, 02:43 PM #20
Similar Threads
-
Problem loading an Image
By onesixtyfourth in forum Java 2DReplies: 1Last Post: 10-17-2010, 11:32 AM -
Problem with loading image
By m00nchile in forum New To JavaReplies: 5Last Post: 05-25-2010, 01:34 PM -
Problem in loading Image
By rahulm87 in forum Java 2DReplies: 1Last Post: 09-08-2009, 04:45 PM -
Loading image in applet
By syarizma in forum Advanced JavaReplies: 0Last Post: 08-06-2009, 09:02 AM -
loading image into applet
By balaram in forum Java AppletsReplies: 1Last Post: 11-06-2008, 02:13 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks