15

I just saw a video showing how Notch (of Minecraft fame) is debugging and changing Minecraft while it is running. He pauses the game, changes something in the code and then unpauses the game where the change takes immediate effect without the need to restart the program.

How does this work? Which kind of technique is used to achieve this?

4

Java can do hot-swapping out of the box. If you use an IDE like Eclipse it will work for changing method-bodies. If you want to apply other code changes you might want to use a tool. JRebel is a product that supports more cases.

I don't want to do marketing for that product, but I personally do not know any other alternative. On the JRebel website there's a nice feature-comparison.

Hope that helps.

| improve this answer | |
  • +1 JRebel is great for "hot coding" outside of an IDE such as Eclipse. – Jalayn Feb 16 '12 at 9:52
4

It's called hot code replace and allows an IDE to change live running code via the debugging interface. It has been supported by the Sun JVM since Java 1.4.1

However, unless you use the (commercial) JRebel JVM extension, it's limited to changes inside method bodies. If you add/remove methods or classes, or change signatures, you have to restart the JVM.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.