Intellij does not seem to be doing basic hot code swap on 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 modify the string at method2(), hit ctrl+s and continue to step by step. Unfortunately the runtime is not updated, old string is being printed. Full stop - compile - run does print the new string. So my conclusion is hot-swap not working.
Is there any settings I need to set to enable hot code swap?
Ubuntu, JDK 1.6
Intellij 10.5 Ultimate (evaluation)
After saving your class while waiting on your breakpoint just recompile your class with Build -> Compile 'MainTest.java' or press Ctrl+Shift+F9 with the standard key bindings.
IntelliJ IDEA will then show a small dialog in which it asks you if you want to reload that class.
After below modifications and enabling hot swap, a change in a Java file took 1-2 seconds of restart time. (Initial start time is around 7 seconds for me).
I hope below method helps...
First, you need to check “Make project automatically” in preferences menu.
To open preferences menu;
you can go to top menu and click;
IntelliJ IDEA -> Preferences
or you can type below shortcut via keyboard;
cmd + option + s
Then, you can check Make project automatically as in below picture;
Secondly, you need to modify compiler.automake.allow.when.app.running registry setting as true.
To open registry, you need to click below keyboard shortcut:
cmd + shift + a
Type registry as in below picture, select Registry, and hit enter button of keyboard;
After Registry window opened, type compiler.automake to see compiler.automake.allow.when.app.running option, and check it as in below picture;
Then, you need to restart IntelliJ to make registry changes work.
There is a Debugger > HotSwap option in intellij 11.
Go to Setting --> Select Debug --> HotSwap
I wanted hotswap to automatically run every time I saved a Java file. None of the other answers did this so I just:
Created a macro that will run on save: https://stackoverflow.com/a/5581992/14731
Added Action: Hotswap at the end of the macro (Run -> Reload Changed Classes)
I think you are asking about this,
Right-click on your java class
Select Compile And Reload File
For anyone experiencing the same problem as me, you might have incurred in the following recent bug affecting the 2020.2 update: https://youtrack.jetbrains.com/issue/IDEA-247530?_ga=2.116305920.729836936.1599654650-984156210.1599654650
TL;DR As a workaround, you need to re-activate the Groovy plugin.
I encountered this problem on Ubuntu. I also had an apparently unrelated issue where IntelliJ gave an error about the file watch limit (my apologies that I no longer have the exact error message). To solve this later issue I did the following steps:
Add the following line to either /etc/sysctl.conf file or a new *.conf file (e.g. idea.conf) under /etc/sysctl.d/ directory:
fs.inotify.max_user_watches = 524288
Then run this command to apply the change:
sudo sysctl -p --system
Now my React components rebuild and hot swap just fine.
Source
Related
For any change I made to my class, which contains a main() method, I have to run "Build->rebuild project", to make the changes effective. I am afraid my environment or settings have a problem.
Please help.
Please check that you still have Build step in the Before launch setting of the Run/Debug configuration. This is the default, but you could have removed it by accidentally clicking on the — icon.
I think you'll have to repeat this for every JUnit test case.
To alter the behaviour for all test cases:
Run -> Edit Configurations...
In left-hand column, select Templates -> JUnit
Make your changes
Hit OK
I had the same problem and I solved it setting the SDK. You need to go in Project Setting and select the Project tab, as show below
Then you can download a JDK or add a new SDK. Finally, you click on OK and run the code.
Couldn't find the simple solution on SO, so thought I would add this here for anyone looking in the future.
My symptom was that I could copy and paste within the IJ editor, but not from the editor to another application or from another app to the editor.
This was on Windows 10 with IntelliJ IDEA 14.1.6.
I have found the best solution yet (for me in any case). I have tried everything! Including adding and removing Keymap options. And this is actually where the problem lies...sort of.
When you have the Vim plugin installed, Ctrl + c and Ctrl + v is allocated to Vim.
To change that, go to Setting>>Other Settings>>Vim Emulation and set the Handler to IDE. Apply and OK, and Voila!
My solution (thanks to a similar issue reported with Android Studio) was to run IntelliJ as an admin.
Steps to always run IntelliJ in admin mode:
Right-click on IntelliJ icon in start menu search (or wherever you started it) -> Open file location
Right-click IntelliJ shortcut -> Open file location (yes, again to get to the .exe, not the shortcut.)
Right-click idea.exe -> Properties
Compatibility tab -> check Run this program as an Administrator
Right-click idea64.exe -> Properties (if you run IntelliJ in 64 bit mode)
Compatibility tab -> check Run this program as an Administrator
Same problem drove me completely insane but this
https://www.quora.com/Why-doesnt-Ctrl+V-and-Ctrl+C-work-in-IntelliJ-IDEA-14-0-2-on-Linux
worked for me:
You might try Ctrl+INS for copy and Shift+INS for paste and see if they work. They are the traditional cut and paste and have been around a lot longer than Ctrl+c/Ctrl+v.
i don't know why, but this worked!
To make copy/paste through shortcut keys working with Vim Plugin you need to change some settings of Intellij IDE's editor regarding vim emulation, you need to follow these steps for it:
Click Menu File > Settings... (or use shortcut Ctrl + Alt + S)
Select Editor -> Vim Emulation and find the shortcuts and change their Handler column value to IDE as shown in the screenshot below.
The Shortcuts will start working, happy coding :)
Another solution i've found
https://code.google.com/p/android/issues/detail?id=173201
was:
Try to minimize Idea window and move it on the same monitor where is the code that you want to copy and paste it. After this small minimize and move exercise the clipboard starts working.
Ctrl-Shft-V starts working after this for me!!!!!
Try to enable "Use national layouts". Settings- Keymap.
For some reason it worked for me.
PyCharm - Setting>>Vim Emulation Set - Control + V/P/A to IDE
I try to write some code... while at it the auto build kicks in (or I just manually build) since this action can take some time, I go on typing...
As soon as the build is done, and when it finds errors it just opens the file of the first error and jumps to the error line where I go on typing there...
Where is the off switch for that feature, please?
#yole was pretty close...
File -> Other Settings -> Default Settings -> Compiler -> Automatically show first error in editor.
Why things has to be so cryptic???
Settings | Compiler | Automatically show first error in editor
If you open up a class with a publis static void main(String[] args) {} method in Eclipse and hit run, then that class will run. If you move to another class with its own main() method and hit run, then that class will run. Is this possible in IntelliJ IDEA? Or will I have to manually change Run configuration every time I want to run something other than the current run configuration?
You can right click on the class in the Project view and select 'Run YourMainClass.main()'
Alternatively in the text editor with that class open you can right click anywhere in the window and select 'Run YourMainClass.main()'.
Or if you don't want to right click there's a shortcut too (should be displayed in the right click menu - differs by OS)
Doing this will save a configuration in the dropdown as well, so if you go in the edit configurations dialog there you can add vm parameters or any options that need to differ from the default. Configurations created like this have a semi-transparent icon to differentiate them.
I am trying to set breakpoints, nothing happens for couple of classes that I compiled recently with "mvn install". I am able to set breakpoints to classes which were already built by someone else.
Please let me know if anyone knows how to solve it.
Had the same issue while using IDEA CE 15:
Removing the Python CE plugin 5.0.143.103 fixed the issue... but no Python parsing! :(
File -> Invalidate Caches and Restart helped solve the problem. Thanks Tomasz Nurkiewicz for the directions
In my case, the issue was caused by PHP Plugin (https://plugins.jetbrains.com/plugin/?id=6610). Even after "Invalidate Caches and Restart", the issue persisted.
Uninstalling that PHP plugin, solved my problem.
By nothing happens do you mean that breakpoint isn't hit? Take a closer look at breakpoint icon. Especially see the difference between
and
icons. The latter indicates the code you run while debugging doesn't have any meaningful instruction on that line.
One of the reasons for such behaviour is when code you run is not the code you see. It can happen when application server can is still running old JAR or something similar. This seems to be the case since you say that breakpoints work in older code.
The solution to fixing breakpoints was adding the wildcard file extension "*.py" to the Python File Types in Python (it must have the wildcard symbol prefix, not just ".py") through taking these steps:
Go to:
IntelliJ IDE > Preferences (CMD+,) > Editor > File Types > Recognized
File Types
Under "Recognized File Types" heading:
Scroll down; Select "Python"
(associated Registered Patterns will be shown below)
Under "Registered Patterns" heading:
Click "+" icon; Enter "*.py", Click OK
(do whatever is necessary to achieve this, including removing/renaming others without the wildcard if necessary)
Add breakpoints by:
Select line(s) of code (not an empty line or comment); Going to: Run >
Toggle Line Breakpoint (CMD+F8)
Configure debugging with breakpoints by going to:
Run > Edit Configurations...; Click "+"; Select "Python"; Add a value
for the "Name" property; Select location of the ".py" file to debug
(in the "Script" property); Click OK
Debug using the breakpoints by going to:
Run > Debug... (Fn+CMD+F9); Wait until it stops at a breakpoint;
Inspect variable values shown in the file itself by hovering over
variable; Click variables and view the Frame and Variable details in
the Debug window by going to: View > Tool Windows > Debug (CMD+5)
Important Note: Initially I tried doing the following but after each one I was still unable to use breakpoints afterward:
Removing and reinstalling the Python plugin:
Entering CMD+,; In the dialog window going to Plugins > Install
Jetbrains Plugin.. > "Python" > Install
Updating IntelliJ Ultimate edition to the latest version v2016.3.4
Going to:
File > Invalidate Caches and Restart
Right click on the gutter (where you normally click to set breakpoint)
select "Configure Gutter Icons..." then enable the checkbox at the top that says
"Show gutter icons"
That fixed it for me
Simply closing and reopening file worked in setting gutter breakpoints
This is embarrassing but posting here in case this solution will help somebody else: A breakpoint will not show up if you attempt to place it between executable lines of code. The breakpoint must be located on an executable line of code to work. Make sure you click on the gutter next to an executable line or place your cursor on an executable line when you use the shortcut. Once I did this, the breakpoints worked.
"Click the gutter at the executable line of code where you want to set the breakpoint." https://www.jetbrains.com/help/idea/using-breakpoints.html#set-breakpoints