How to enable Intellij fast code exchange

Intellij does not seem to do the basic replacement of the hot code during my installation.

For this code:

public class MainTest { public void method1() { System.out.println("Breakpoint here"); } public void method2() { System.out.println("Line that will get 24 modified"); } public static void main(String[] args) { System.out.println("First print here"); MainTest mainTest = new MainTest(); mainTest.method1(); mainTest.method2(); System.out.println("Line that I do not modify"); } } 

I put a breakpoint on mainTest.method1(); , then changed the line in method2 (), hit ctrl + s and continued step by step. Unfortunately, the runtime is not updated, the old line is printed. Full stop - compilation - start printing a new line. Therefore, my conclusion is a "hot swap" that does not work.

Are there any settings I need to set to enable hot-code sharing?

  • Ubuntu JDK 1.6
  • Intellij 10.5 Ultimate (rating)
+54
intellij-idea hotswap
Jun 19 '11 at 11:45
source share
6 answers

After saving your class while waiting for a breakpoint, simply recompile your class using Build -> Compile 'MainTest.java' or press Ctrl+Shift+F9 with standard key bindings.

IntelliJ IDEA then displays a small dialog box asking if you want to reload this class.

+70
Jun 19 '11 at 12:21
source share

After the following changes and enabling hot swapping, changing the Java file took 1-2 seconds to restart. (The initial launch time for me is about 7 seconds).

I hope the below method helps ...




First, you need to check "Make the project automatically" in the settings menu.

Open the settings menu;

You can go to the top menu and press;

IntelliJ IDEA → Settings

or you can enter a shortcut below using the keyboard;

cmd + option + s

Then you can check the box " Make project automatically as shown in the image below;

enter image description here

Secondly, you need to change the registry setting compiler.automake.allow.when.app.running to true.

To open the registry, you need to press the key combination below:

cmd + shift + a

Enter registry as shown in the figure below, select Registry and press the enter button on the keyboard;

enter image description here

After opening the Registry window, enter compiler.automake to see the compiler.automake.allow.when.app.running parameter, and mark it as shown in the figure below;

enter image description here

Then you need to restart IntelliJ for the registry changes to work.

+8
Dec 29 '16 at 10:21
source share

Intellij 11 has the Debugger > HotSwap option.

+5
Aug 23 2018-12-12T00:
source share

Go to Settings → Select Debug → HotSwap

enter image description here

+2
Aug 19 '16 at 5:10
source share

I ran into this problem in Ubuntu. I also had a clearly unrelated issue when IntelliJ threw an error about the time limit for viewing files (my apologies that I no longer have an exact error message). To solve this problem later, I took the following steps:

  1. Add the following line either to /etc/sysctl.conf or to a new * .conf file (for example, idea.conf ) in the /etc/sysctl.d/ directory:

     fs.inotify.max_user_watches = 524288 
  2. Then run this command to apply the changes:

    sudo sysctl -p - system

Now my React components are rebuilt and the hot swap is just fine.

Source

0
Feb 01 '18 at 16:51
source share

I wanted hotswap to start automatically every time I save a Java file. None of the other answers did this, so I just:

  1. A macro has been created that will be executed upon saving: https://stackoverflow.com/a/167189/
  2. Added Action: Hotswap at the end of the macro
0
Jan 19 '19 at 19:49
source share



All Articles