Stop debug mode in IntelliJ IDEA when using Gradle - java

I used a hint that said use Run with --debug, so I clicked on it. How can I remove the feature to get an output as usual?

Clicking this link will create a new temporary configuration for Gradle that will have --debug argument added there:
You can either remove this argument from the configuration or delete this configuration completely and continue using your existing run/debug configurations without this option.
More details can be found in IntelliJ IDEA help.

Click the red square on the top right, like here:
Alternatively you can also press it in the tab where you can control the debugger, which is on the down left:
If you don't see that, make sure to click on "Debug" on the bottom bar.

Related

Run/Debug are not working in IntelliJ IDEA

I've installed an IntelliJ IDEA Community Edition 2018.2.4 x64.
I've cloned a Project from Git (I learn a course on the "coursera").
The first task was:
"Click the green arrow at the left side from the code.."
I haven't any arrows. I can't run it from main menu, the programm ask me about configuration. What exactly I need to do?
"Run" is not available.
Asking about configurations.
Configuration's window.
The problem solved.
It was fun.. The firewall blocked all functions of mavel,jdk and part of IDEA. Adding to exceptions didn't help. Switching off the Firewall - helped.
Strange were: Empty repositories of maven, the same settings as at the another computers where it have worked.
Now everything is working.
You have to create a new configuration for Kotlin and specify the main class which would be lesson1.task1.SimpleKt. Then the disabled arrow will turn green and be clickable.
If you want to run the other examples you have to create a new configuration for each one since they all have their own .kt file with a main function.
Right Click on Project Folder->Module Settings -> Add src folder in sources in the following way

IntelliJ Debugger catching wrong file with same name

I have two files with same name in two separate packages package1 and package2 in same maven project. I added a debug point at line i in the file that is present in package1. But while debugging, the IntelliJ IDEA debugger stops at line i of the file present in package2. This has been occurring with a few of my fellow mates as well. Is there any such bug reported with IntelliJ ? Any fix or workaround ?
You can turn on Show alternative source switcher flag under Settings >> Build, Execution, Deployment >> Debugger.
Check show alternative source switcher check box, and IntelliJ IDEA will allow you to change required file.
Now, when you are debugging, IntelliJ IDEA should provide you other options to chose among source files.
To add on to the accepted answer, if you already have the setting checked but the alternative source switcher is not showing up, I found that toggling the setting off and back on bring the switcher up. On IDEA 2022.1.

Removing breakpoints in Eclipse

I use Eclipse as IDE and I have a problem with breakpoints in this one. I have two projects - an android that I use as client app application and another one that I use as library for first one. Previously i have created an breakpoint in code of library application. Then this breakpoint was removed from sources. But now when I debug my code this breakpoint still hits (the file with *.class extension is opening and this breakpoint is showing). How can I disable or delete it?
Open the project > select the debugging view >> Somewhere in that view there will be a window titled Breakpoints. From there you can remove the breakpoint you want to get rid of.
In eclipse try the following:
Goto windows -> open perspective -> other -> debug
click on Breakpoints tab in the
Remove all/specific breakpoint by clicking on either cross/double cross button

How do you step through a program in Eclipse?

I want to follow a Java program so that I can understand how everything works together. I could do it with Visual Studio so I am hoping that Eclipse may also have a feature to step through that I have not been able to find.
Put a breakpoint at a given line (double click before the line, or right-click > toggle breakpoint)
Run the program in debug mode. That is - Debug As > Java program
Whenever the breakpoint is reached, the Debug perspective opens, and you can step through.
Refer step1, step2, step3,step4 images respectively.
Simply put, you can run your code in Debug Mode by pressing only F11 or clicking that little bug on the top of the screen. Use F5 to trace into, F6 to step over, CTRL-SHIFT-B to set/remove breakpoints.
First you must set a break point in your code. The easiest way to do this is to open up the source file where you want to stop your program, find the line of code where you want to set your break point, and right-click the left-hand margin and select 'Toggle Breakpoint.' Once you've done this, launch your program within Eclipse using the Debug mode. To do this, go to Run>Debug Configurations and set up the configuration to run your program. Alternatively, you can open up the source file that is the entry point to your program (it should include your 'public static void main(String args[])' method), and right-click within the editor and go to Debug As>Java Application. Once the program launches and the code in which your break point is reached, Eclipse will open up the debug perspective. This will show where you are within your program and any variables that you have set. You can step through your program using the buttons in the 'Debug View'. You can also use the menu items within the Run menu to step through the program.
All the answers here are not really "cut and dry". To make this debug feature available in the eclipse workspace, first, you need to set the breakpoint properties of Line Breakpoint. Check the box: "Trigger Point" to allow the trigger to initiate at the line that you want it to begin to break during debug mode. Otherwise, you can F11, F5, or F6 all day long, and nothing will allow you to step into your code.

Eclipse shortcut to run a class

I have an Eclipse project where I often launch the same java class. I have added my run configuration to the favorites menu, but to launch it I still need to click on the run-drop-down menu and click the icon - is there any way to associate a shortcut to this? When I searched for it I got lost in all the plugins & other things which seemed to be not so simple.
edit: Let me clarify, I want something I can type the moment I start eclipse, regardless of what page I'm viewing, so no "run last" or "run current"; I want F12 to link to "launch foo.bar.MainClass".
Just use Ctrl + F11. (This is the standard keyboard shortcut to run the class you are working on)
I wish this is what you are looking for... buddy.
Open the workspace preferences by the menu: Window > Preferences
Select from the tree: Run/Debug > Launching
Now the Launching preferences are seen.
At the bottom there is Launch Operation
Use the option Always launch the previously launched application
You can configure your launch behaviour so Ctrl-F11 will launch the last launched application again, regardless of your current editor selection.
Look at "Run/Debug" - "Launching" within the eclipse preferences.
alt+shift+x+J Rocks
You can go Window -> Preferences -> General -> Key and bind anything you want!I hope it helps!
You should put in a feature request in the eclipse bug tracker (or vote up an existing equivalent feature request) or code it yourself.
It is Ctrl+F11
Ctrl+Shift+X or Ctrl+Shift+J didn't worked for me!
If you've added these classes to your favorite run configurations (available from the run/debug toolbar buttons as "Organize Favorites..."), then the shortcut key combo is Alt+R,T,1 to run your first favorite, Alt+R,T,2 to run your second, etc. Alt+R,H,# works for debug configs.
on Windows machine
ctrl+Fn F11 --- running
ctrl+Fn+Shift F11 --- debugging
If you are someone like me who wants to create a shortcut to run a class/program in java directly, you can create your own preferable shortcut in ECLIPSE!
Follow these steps:
Window > Preferences > General > Keys
Select run from command column
Enter your own shortcut in Binding section
Apply and close!!
WARNING: Make sure you don't create a shortcut which is already assigned for a different task!
I cannot this the answer here but : CTRL+SHIFT+T do apparently exactly what you want! :) Maybe it's because you code it by yourself by time...
Watch here: http://eclipse.dzone.com/news/effective-eclipse-shortcut-key for more.
I faced this problem in eclipse too. I have customized the configuration for me.
Windows -> preferances -> keys
Search for your configuration eg "Run Java Application" or just look for its icon.
Select it
and below in the binding field press keyboard keys which you want to add a shortcut for this configuration eg. ctrl + shift + T
and Apply
You are good to go use the same shortcut keys to whenever you need it.
Just create an "External tool configuration" instead of a standard configuration for the class you want to run, and assign a shortcut key to "Run last launched external Tool".
Of course, there shall be no other external tool configuration.
Even if other java programs have been launched, or the current class contains a main() method, hitting the shortcut key will always run the same configured class.

Categories

Resources