16

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?

3
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.

1
  • +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.

0
-1

For VScode, need to:

  1. Enable java.debug.settings.hotCodeReplace
  2. Make sure java.autobuild.enabled is not disabled for VSCode Java
1
  • Welcome... to improve your answer, could you please expand on what you've posted, explaining the settings? – Andrew Jan 23 at 10:22

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