Skip to main content

Texture working on Desktop Application but not in applets

5 replies [Last post]
sikriyogesh
Offline
Joined: 2010-01-18

Hello Friends
i created an applet based application in which I m loading file with some textures as jpg images but when I run this application as desktop version and loads texture then its working fine but when I do same as applet means when i run from browser then its not loading texture.Here is the code below I m using to load texture:

BufferedImage textureImage = ImageIO.read(new File(imageFileName));
int flags = TextureLoader.BY_REFERENCE ;
flags |= TextureLoader.GENERATE_MIPMAP;
TextureLoader textureLoader = new TextureLoader(textureImage, flags);
Texture texture = textureLoader.getTexture();
currentAppearance.setTexture(texture);

Any ideas??

Thanks & Regards
Yogesh

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
aces
Offline
Joined: 2003-07-17

File is not allowed in applets.

Put this image as a resource, in the same folder of you source classes and use something + or - like below :

[code]
URL url = this.getClass().getResource("MyImage.jpg");
TextureLoader tl = new TextureLoader(url);
[/code]

darwinjob
Offline
Joined: 2004-11-16

...or sign the applet with a certificate ;)

Yogesh, we are not psychics here, next time please post the error log.

sikriyogesh
Offline
Joined: 2010-01-18

Thanks Drawin And Aces for ur valuable replies.
To Drawin:I already increase the heap as per your Idea1.
And according to your idea2,might be the possibility as different jres are installed on machine.

To Aces: I cant save that texture in source as I am finding this file at run time which one to load or not.

Thanks & Regards
Yogesh

sikriyogesh
Offline
Joined: 2010-01-18

Thanks Drawin,As per your Idea2 I found the solution but now I am in critical situation.
As I was using Object tag to Load java3d Libraries on browser and those were different from desktop installed libraries.

But with that object Tag with those Directly loaded java3d libraries around 10MB files were loading fine and after that no files are loading.
So,I changed back to applet tag to load jar but without any loading java3d.And It works fine for all sizes file.Now the prob is If any user doesnt have java3d library then how do i load those java3d library and It is not sure if i load some other way then those java3d library will match.So,PLease advice me.

Thanks And Regards
Yogesh

darwinjob
Offline
Joined: 2004-11-16

Idea 1:
Heap size. When you run as an applet it uses 64M of memory by default. Try to increase it.
Idea 2:
Browser's default Java/Java3D is different from the default for a desktop application. It happens when you have several JRE/Java3D installations on the same machine. Make sure that you have only one the latest JRE/Java3d installed.