0

Possible Duplicate:
How to write a self-updating program in Java?

So, i have a question for you guys. I'm making a game, and i want it to be updateable, such as minecraft or guild wars 2 or any other good game is. my question is how. i have been doing a bunch of looking and i cant really find any good ideas. i already have the connection b/w the server and the client, and so what i need is the transfer of the new files and then replacing the old ones. i'm using the socket approach, because i think that is the only way... but i'm not sure. what i had: a class in both programs called updateClass. it was the exact same in both. i then had the server send the object over to the client and had the client read the msg embeded within the object, just as a simple test. it said that it was unable to send the object. i had it casted at the recieving end, so im not sure. my question is, am i on the right track? any ideas or suggestions? i'm not looking for specific code, but if you have some i welcome it, i like the challenge. also, how would i get my program to update its class files? seems like it shouldnt be able to while running, which is a slight problem... so let me know what you guys think! thanks in advance!

Community
  • 1
  • 1
PulsePanda
  • 1,806
  • 10
  • 33
  • 56

3 Answers3

1

Maybe this tutorial can give you some idea:

http://www.mkyong.com/java/java-web-start-jnlp-tutorial-unofficial-guide/

Or this one :

http://www.hascode.com/2012/05/creating-updatable-java-applications-using-getdown-and-the-getdown-maven-plugin/

Yves_T
  • 1,170
  • 2
  • 10
  • 16
1

You should send binary definition of your class (content of .class file) over network and load it into VM using ClassLoader.defineClass(String name, byte[] b, int off, int len). Serialized version of class is not java bytecode for class. Take care that you can not unload class once loaded, so you can not update them in same classloader.

Nemanja
  • 1,161
  • 11
  • 13
1

..am I on the right track?

A much easier 'track' to provide updates for a J2SE app. is to deploy it using Java Web Start.

Automatic update is one of the many advantages that comes with JWS 'out of the box'. More recent JREs even allow the app. itself to interact with the API that does the updates.

Community
  • 1
  • 1
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433