Hi to everyone, once again. I’ve made my applet and locally it works ok. Now I’m just trying to resolve some problems with serving it from a web server.
In the applet I open a few .tga files that are used as textures. The problem is I can’t understand the relative path to open the file.
The classes are in a jar file. They’re also in a package (say com/mycompany/myproject) so in the jar file they’re under this path. Now what I’d like to do when I load the files is:
texture[i] = LoadTGA(“tex” + i + “.tga”);
I checked the permission and fixed them, so there’s no security problem at the moment. But how do I load the images? For this to work I need to pass the absolute path, which is a bit inapropriate. For the above code I get a NullPointerException so I suppose it can’t find my images. So where do I need to place the image files for this to work?
well u should try the classloader
u can acces it through:
this.getClass().getClassLoader().getResourceAsStream();
javadoc: http://java.sun.com/j2se/1.5.0/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)
also there are methods with wich u can find ressources in ur jar file
the way over the classloader is very good for applets cause u can read with no privilegues (an unsigned applet) without causing security exceptions
but iv forgotten how to get the path to a ressource in a jar…
at this point u should try a bit… and find out how the url in the jar looks like…
btw sorry for my bad english… i dont speak english as my native language
i hope u did understand me anyway