Dang… Nobody?? Oh well… I ended up figuring it out after messing around a bit.
After researching this topic I have found tons of posts with people asking the same question, none of them ever really seeming to find the solution to their problem. I would expect there to be resources for this topic out there somewhere, but after hours of searching I found absolutely nothing. When searching ‘Applet deployment’ basically all that comes up, is how to embed applets in a webpage… Great… I saw person after person asking ‘Why do my images not show when run through the browser, but work fine when run in my IDE?’ I then saw people throwing around very vague answers like ‘add image parameters in html’ or ‘download this applet bundling program…’
The solution is extremely simple (at least with the problem I was having) and so I will post it here, to hopefully save someone the trouble I just went through. My Images folder for my project was a separate folder, which was called as a resource through the Java Build Path. This works fine when running the project through eclipse or command line, but does not show the images when run through a browser.
So I copied my images folder into the source folder and erased the old Images folder. Then adjusted my code to read from the correct path.
Image treeimg = getImage(getDocumentBase(), “…/Images/tree.png”);
Image treeimg = getImage(getDocumentBase(), “Images/tree.png”);
It now shows my images on the browser. I guess the reason is, when exporting an applet, files in the source folder are automatically compressed into the Jar file. So my understanding is that it is best to keep resources along with source (for Applets) I guess? I am sure there are other ways, but after hours of fuming over this, this seems like the easiest solution and works fine.
Anyways, I just hope someone else can use this info because it doesn’t seem to me that anyone else has taken the time to explain this very well. As long as you are putting everything in the correct path, this should work fine.