FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Java - Can't load resources





catscratches
I'm making a small Java "game" and everything's been working fine so far. This is how it looks when I run it on my own computer:


However here's how it shows up when I upload it to FriHost:
http://catscratches.frih.net/cross/Main.html


It's the exact same files and I'm keeping the exactly same file structure. I also run it with the very same browser (Firefox to be more precise).

This is the code I'm using to load an image (the sky, more precisely):
Code:
bgSky = getImage(getCodeBase(), "images\\bg_sky.png");


This is the embedding code:
Code:
<applet codebase="classes" code="okdab/Main.class" width=600 height=378></applet>


The java class is located in classes/okdab/Main.class and the images are in classes/images/*
(I have, however tried to copy the image folder to both ./ and classes/okdab/ to no avail, so I'm pretty sure that the location is not the problem.)

I'm having the same problem with the background sound as well. It is loaded in a similar fashion so I presume that the problem is the same. It all works when running on my local machine.

Thanks for any help.


Edit:
Ok, now this is just weird. I tried loading the image from the server through a direct URL:
Code:
URL url;
try {
    url = new URL ("http://catscratches.frih.net/cross/classes/images/bg_sky.png");
} catch (MalformedURLException e) { return; };
bgSky = getImage(url);


It worked perfectly... on my local machine. As soon as I uploaded it, it stopped working again.
AftershockVibe
Works for me! :S
Make sure the applet isn't being cached and you're using the one with the updated URL.

Also, for what it's worth, the first version probably didn't work because you're using Windows separators instead of Unix/Java standard separators for directories (i.e. "\" instead of "/").
catscratches
Indeed. I guess I can blame my currently lousy Internet connection.

I changed the separators and it does work for me as well now (although at first it didn't seem like it).

Thread can be closed, I guess.
Stubru Freak
Just for clarification of why it didn't work: the first one didn't work because of the incorrect seperator. The second one didn't work for security reasons: a website can only load images from its own server. So Java refuses to load an absolute URL, you have to use a relative one instead.
Related topics
picture slide show (java)
Java Game
Free Scripts Resources
Complete Tutorial LINKS for every language
Fedora Core 5 Test 1 Review
Recommended FREE/SHAREWARE Software
Java
Apache
Problems with Java?
Programmers: How to...
My java applet can not find class file on the server
Java applet error.
Prevention, detection, and cure: 12 free security programs
Hi all
Reply to topic    Frihost Forum Index -> Scripting -> Others

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.