loading resources in an applet
Hey all -
So i converted a java project into an applet. It runs and works fine in the viewer running off my local HD. So i make and html page and upload the source up onto the server and it loads but none of my textures load. So I think to myself not a problem. I go through and I add in getImage(getCodeBase(), "serverfolder/imagetoload.png"); but i do not get an image. I output the path to make sure it is correct (getCodeBase().toString() + "serverfolder/imagetoload.png") and it is correct and the file is there, but i dont see any image loaded (skybox).
I asked around and the only answer i get is that that is the prefered method to load stuff using a JApplet and to try either a staright URL or classPath load resource thing. Now the URL doesnt work, and I am trying the classPath now, but I want my resources in a seperate jar file, but I am having problems telling my project to look in that jar for the resources. I can do it just fine when i have the resources in the main jar file, but it makes it very bloated and Id rather not do that. Is there a way I can get my application to look in the "resource.jar" for all my images?
Thanks In Advance,
Still Struggling with getting this to work
So these are some things I've been trying. I was thinking that possibly it was the structure of my assets jar so I recreated it. I created a folder called assets and placed two folders in there; one called textures and the other called models. In the command line jar - cf assets.jar -C assets/ . and it created my assets.jar.
In netbeans i went the Libraries in the project and added the assets.jar. The code I am using to create an Image which I then use for my skybox is as follows:
URL imageLocation = getClass().getResource("assets/textures/imilogo.png");
ImageIcon icon = new ImageIcon(imageLocation);
Image image = icon.getImage();
I have a break point set at imageLocation as i debug the Applet when it starts. imageLocation continues to return null. To make sure I was using getResource correctly i placed the images in the same package as the applet class and it still came up null. I've also tried the getImage(URL, file) and that too comes up null. I have run out of ideas on what to do.
Now running it with local calls of loading from a specified HD location works. Basically a ImageIcon icon = new ImageIcon(System.getProperty("user.dir") + "assets/textures/logo.png"); works just fine. I change it to a static URL on the server and again the image i get from the icon is null.
Could you explain more on what your talking about Orange?
Thanks again for the suggestions,