When debugging in eclipse, I believe you are able to change the value of a variable in the source and have it update in realtime without setting breakpoints or anything. I was wondering if the same was possible in intellij?
Same question but for eclipse.
You can reload classes while running your program in Debug mode and changes in code will apply if possible (there are limitations) without restarting the program.
To reload changed classes
Do one of the following:
On the main menu, choose Run -> Reload Changed Classes.
On the main menu, choose Build -> Compile "class_name" to recompile an altered class during debug.
Not aware about any other method to change the value of a variable "in real-time".
Yes, IntelliJ IDEA allows you to see real-time changes while debugging Java code. This feature is called HotSwap, and it allows you to modify your code while the program is running, without the need to stop and restart the debugger.
To use HotSwap in IntelliJ IDEA, you first need to enable it by going to the Run/Debug Configuration dialog and selecting the configuration for your application. Then, in the "Debug" tab, make sure the "Enable HotSwap" option is checked.
To use HotSwap, simply make your code changes in the editor and then press Ctrl+F9 (Windows/Linux) or Command+F9 (macOS) to compile and reload the code in the running program.
Note that not all changes can be applied using HotSwap. Some changes, such as changes to class hierarchies or changes to method signatures, will require a full restart of the debugger. Additionally, HotSwap is not supported in all Java virtual machines, so make sure to check the compatibility of your JVM if you encounter any issues
Related
I use IntelliJ IDEA and want that my class should be redeployed after I make changes. Eclipse can do this. How does this work in IDEA?
I know that in the run configuration there is "On frame deactivation" and I set it to "Update classes and resources", but this does not work.
Do you hit the "redeploy" button every time you made a change in your class?
There are limitations to class reload, in any Java project. It also depends on what you're using to perform this reload (if you're using a servlet container, etc).
By default, IntelliJ uses HotSwap for its reloading. There are some limitations to it though:
At the moment due to original limitations of Java SDK the HotSwapping is possible ONLY if a method body is altered. In all other cases (like changing method or class signature), the class reload is impossible and the corresponding error message appears.
That said, the instructions for configuring your application to reload can be found here.
To configure reloading behavior
On the main menu, choose File | Settings , and then expand the Debugger node.
Open HotSwap page.
Click one of the radio buttons in the group Reload classes after compilation. You can opt to always reload classes, reload after
confirmation, or never do it.
Take a look at HotswapAgent configuration for InteliJ IDEA
Is there a way to include whole Java source code into an eclipse project so the program is easier to debbug (e.g. by inserting println in methods you otherwise couldn't insert anything)?
I have a bug in my code. But to better understand why the bug in my code appears, I'd like to see what intermediate results in some system method (on which use the bug occurs) are.
For example, I'd like to know what JViewPort.scrollRectToVisible() exactly does and how my input behaves in it by printing out some intermediate results that occur in the method itself.
EDIT:
Instead of using JRE System Library X, I want to add the source code from JDK as if I had written the code myself. I want to be able to edit any System class just as I am able to edit any class I created myself. I want editable .java files, not packed .jars...
You would need to add the 3rd-party library to your Eclipse workspace as an project. (How you would do that depends on the code you are dealing with.) Once you have done that, you can hack your copy of the library to add trace prints etcetera.
A better alternative is to simply attach the source code for the 3rd-party library so that the debugger can show you source as you step through the code, set breakpoints,. Then use "advanced breakpoint" techniques instead of trace prints; e.g. http://www.vogella.com/articles/EclipseDebugging/article.html#advanced
You cannot change the library code, but you can view it by using de-compiler. The max you can do is this. Now if you change any code in the libraries which you reached via the de-compiler, you would find an error stating "the integrity of the .jar package has changed which is not allowed"
Eclipse have built-in support for what you wanna do.
All you have to do is set breakpoint and execute application in debugging mode.
You can use these icons in Eclipse debugging perspective.
Follow along Eclipse Debugging Tutorial for details.
I want to manually test some features of a plugin I'm developing. To do so, it'd be nice to be able to create some projects in the test Eclipse instance and have them stay throughout all my testing season. At the moment it seems that Eclipse insists on clearing the Eclipse Plugin workspace. Is it possible to invert its default behavior?
Thanks
Open up the launch configuration for this launch
On the Main tab, unclick Clear so the workspace remains across launches (alternatively, you can select Ask for confirmation... so you can choose each time).
As far as I know, there is no way to mark this as the default.
Is there any method in SWT to programmatically set my plugin as default whenever the eclipse IDE starts i.e. when the eclipse starts a desired plugin is set as perspective.
If I remember correctly, it should be possible with setDefaultPerspective(String id).
You can access this via:
PlatformUI.getWorkbench().getPerspectiveRegistry().setDefaultPerspective(id);
However, be careful when doing this. I can imagine that a lot of people might uninstall your plugin, just because they are annoyed by this small change.
I am building an application in Java using Netbeans IDE. I am trying to debug some errors in my code. But even when I modify messages passed in the log statements, I do not see a corresponding change in the logged messages. This implies that when execute the code, it probably runs an older version of code & prints the old version of log messages as well.
What is the cause of this error ? & how should I rectify this ?
Thanks for helping..
I had that same problem...closing and reopening netbeans fixed it for me...
By saving the code. I assume, you are have compile-on-save enabled. If not then you have to build it before running it.
Yes you need to enable build-on-save, otherwise GlassFish wouldn't be able to show you the changes, because the new changes have never been deployed. Sometimes, deploying on save bothers a lot. So, what I do is, I don't enable build-on-save and work with tests and thereby run my tests to see the result of the change. When everything seems fine, then I build the app and deploy it on the server for further verifications.
Compile on save must be set.
See the properties of your project.
(Right click, select properties, then select compile).
Another possibility is that you have to redeploy
your project. In such a case I would recommend to
take a look at jRebel.