Archived

This topic is now archived and is closed to further replies.

[java] I need some help.

This topic is 5145 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well, I''m making a online multiplayer game (not saying any details) but i was wondering if is possible to update it over the internet even though you will have to download my game onto your computer. For example say a person downloads it and starts playing (remember that this is an online multiplayer game) but then i want to add a new item to the game, so can i make it so the game updates and the new item will be in the game and the person can use it? A person I know says this is impossible, that they will have to redownload a different version of the game that has the item in it. So my question is "can i make it so the game updates and the new item will be in the game and everybody can use it?" because I don''t want people to have to redownload the game everytime I add something new into it.

Share this post


Link to post
Share on other sites
If im understanding you right, you could just transfer it to them, without them even knowing im guessing. I dont see why theyd have to re-download the entire program. What my group did for a project a ways back was, check a hard-coded version number against the current server one, if it was different, we''d send them the new files, and off theyd go. That way the user didnt have to redownload everything. Hope that helps. o_O

Share this post


Link to post
Share on other sites
A Java "program" is really just a loose bundling of classes. Java is very dynamic, and downloading new items into a running game is definitely something Java can handle. You''ll need to get to know class loaders, and probably URLClassLoader would do what you need. If not you may need to write your own class loader, which is fairly involved but not too bad. Then with class loader in hand, your game can load new classes whenever it wants, then create objects out of them. Being an online multiplayer game possibly complicates things, but it''s definitely doable.

Share this post


Link to post
Share on other sites
You would only have to deal with class loaders if you wanted to update the game while it was being played. If you wanted to do a check before the game starts, that would be even easier. Just write a little check program that runs before your game loads any classes. Have it download all the new files, then start the game. The new classes will automatically be picked up.

Your biggest problem would be if your program is in a jar file. You then either have to add the new files to the jar file or download a separate jar and make sure the separate jar is in the classpath ahead of the main jar.

With the second option, you will start having a lot of jar files floating around. With the first option you just have to write a bit of code to add the incoming files to the existing jar. This is not too difficult as the SDK has built in APIs for handling jar/zip files.



First make it work,
then make it fast.

--Brian Kernighan

The problems of this world cannot possibly be solved by skeptics or cynics whose horizons are limited by the obvious realities. We need men and women who can dream of things that never were. - John Fitzgerald Kennedy(35th US President)

Do not interrupt your enemy when he is making a mistake. - Napolean Bonaparte

Share this post


Link to post
Share on other sites
Thanks everybody, now that I know that it is possible to do that I can finally start making my game, without having to worry about that problem. Thanks again.

Life...
Its the one thing we all have...
Its the one thing we can all lose...

Share this post


Link to post
Share on other sites