![]() |
< Day Day Up > |
![]() |
Recipe 5.14 Changing Code on the Fly5.14.1 ProblemYou see a code error, and you want to fix it and test the fix, all without restarting the debugging session. 5.14.2 SolutionIf you have Java Version 1.4 or later, just edit your code as you're debugging and save it (provided the auto-build on save capability is turned on), and you can keep debugging. 5.14.3 DiscussionThe process of editing code while debugging is called hot
code replacement, and you'll need Java
Version 1.4 or later to use it. Make sure the
"auto-build on save" capability is
turned on (it's on by default). If it
isn't, turn it on by selecting Window Now debug your code until execution stops at a breakpoint. At this point, you're free to edit your code. After editing, save the code and resume execution.
Note that you have to use Java Version 1.4 or later to support hot
code replacement. If you're targeting an earlier
version of Java with the actual code you're
developing, in Eclipse you can use different JREs to run and debug
your code. If you want to set the debug launch configuration so that
it uses a different JRE, select Run 5.14.4 See AlsoRecipe 4.8 on selecting the Java runtime. |
![]() |
< Day Day Up > |
![]() |