java cache

Hi, we have a little 3d thing running in a jogle applet. We have noticed that everything is cached by the JRE except for a couple of large textures. The limit appears to be around 2.2mb.

In other words, the really big files that we would like to be cached, are not.

Anybody know how to change this behaviour?

Thanks for your help.

If I remember well, Thijs explain somewhere that there is a trick to cache anyfile by renaming it to .class file : picture.jpg => picture.class maybe it also requiere to load the file using a certain way but I cant remember exacly :frowning:

Yup,

Rename your resource files to .jar, download them over an urlconnection with setUseCache set to true (or false if you dont want to cache). Read in the byte[] and feed it to a zipstream and your done. If you try to load it with cache set to true, it will load the resource jar from the applet cache if its there. The only downside is that during the download (with caching on) the urlconnection wont tell you the nr of bytes it downloaded. This is because of some stupid implementation detail, if setUseCache is enabled, it’s downloaded in an private stream somewhere deep in Suns classes. That stream is passed until the whole jar is downloaded and cached to disc… so no progress monitoring is possible :confused:

EDIT: .jar should read .class :-X

You can also manually cache by storing the file at user.home + .whatever/ and you basically have your own resource folder on their HD.

Thats only possible with webstart and signed applets I’m afraid. If they use the JOGLAppletLauncher they wont have those rights from their own classes