Sign in to follow this  
smr

[java] Streaming content and local caching with webstart?

Recommended Posts

smr    2468
I'm new to Java development and am working on my first Java game. I've been getting along with Java pretty well so far, but there's one thing I'm struggling with. My game will have lots of content. Megabytes of it. It's going to be infeasible to send all of it down the tubes before the game begins. What I want to do is demand-load and cache content locally. How can I do this within a webstart application in a platform independent, webstart-y way? Is it OK to read and write directly to the filesystem from within a webstart application? If so, how do I know where it's safe to do so? Can I get write access into the users' home directories or is there some sort of sandboxed folder on the filesystem that's "all mine?" I've read about muffins and I don't think these are the right solution. Thanks!

Share this post


Link to post
Share on other sites
domstyledesign    100
basically your program will be thrown into a sandbox and prevented access from the filesystem and the network (except for the site which delivered the application).

if you want extra security access, you'll have to sign your code.

though, you really shouldn't have to. If you're downloading content from the same site from which users are launching the application, why do you need to write it to a file? if you did, the flow would be like this:

web server -> java app (RAM) -> disk -> java app (RAM)

why not skip those last two steps? reading from a file stream and reading from a network stream are basically the same thing (conceptually and code-wise)

*edit

re-read your post, somehow missed the "caching" part. i guess what i mentioned above really depends on your app: how often you request data, how large the data requested is, and how often/when that data is used, etc.

if you really really really just want to write files to the disk, sign your jar.

Share this post


Link to post
Share on other sites
Argus2    140
Quote:
Original post by domstyledesign
web server -> java app (RAM) -> disk -> java app (RAM)

why not skip those last two steps? reading from a file stream and reading from a network stream are basically the same thing (conceptually and code-wise)

Except that it would be more network traffic for the webserver, and could cause delays with frequent/large read/writes. Here's an article explaining file-system access for WebStart applications (Googled..) :

http://www.builderau.com.au/program/java/soa/Work-with-Java-Web-Start-beyond-the-sandbox/0,339024620,320269115,00.htm

Regarding caching, I've always found WebStart apps to be cached pretty well - I think that's a browser decision, but you may be able to hint to cache. I'd run a simple test to see whether it caches under normal browser settings and leave it at that to start with.

Share this post


Link to post
Share on other sites
domstyledesign    100
Quote:
Original post by Argus2Except that it would be more network traffic for the webserver, and could cause delays with frequent/large read/writes.


this is correct. as i said, it depends on the nature of the application itself

Quote:
Original post by Argus2Regarding caching, I've always found WebStart apps to be cached pretty well - I think that's a browser decision, but you may be able to hint to cache. I'd run a simple test to see whether it caches under normal browser settings and leave it at that to start with.


let's make sure that you and the OP are talking about the same kind of caching. it sounds like the OP is talking about caching data to be used by the application, and you referring to caching the application itself.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this