usually when I debug java by pressing on the bug icon, it starts debugging right away and goes to the debug perspective...
but now everytime I click on the bug icon, it always opens up the debug configuration window rather than actually debugging....
any idea as to how to make it debug right away once again?
This usually happens if you have configured Eclipse to "Always launch the previously launched application" (Preferences>Run/Debug>Launching) but Eclipse can't find a previously launched application. Does this happen again if you configured the debug configuration once, debugged successfully with this configuration and then try to rerun it?
Or you could change this setting so Eclipse always tries to run/debug the currently opend file, then it will behave like Ed described it.
If it has a saved configuration for the currently active file in the editor, it will automatically use it. Otherwise, it will want you to tell it what you want. I'd suggest getting in the habit of using saved configurations (down-arrow on the debug button) that you've set up.
You could install 'Eclipse Runner' via marketplace. It's a nice addition of run/debug feature.
I faced the same problem. I defined the debug configuration and run my Junit but my eclipse was crashing again and again.
I restarted my eclipse and my debugAs menu is back to two options [Debug on server or debug as Junit].
Hope it might help.
Related
I have a gradle project, and when I put a breakpoint it is displayed as a red dot, with a tick inside, and it just works fine.
The problem is that in some classes (in the same project, not a dependency class), the red dot doesn't have a tick inside, and it doesn't tell why it wouldn't work. And it just doesn't work..:
What have I tried so far:
Gradle clean & build
Rebuild project
Restart debug
Invalidate caches and restart IntelliJ
Update IntelliJ to the latest version (2017.2.5)
Mute & Unmute breakpoints
This question is similar, but clearly not the same: Intellij IDEA: Breakpoint not being hit, and is shown greyed out
Did some searching through IntelliJ Help PDF:
Help Doc pg. 431
Their documentation Describes the checkmark as "Shown at run-time when the breakpoint is
recognized by the debugger as set on an
executable code line."
and the regular red dot as "Shown at design-time or during the debugging
session when the class with such breakpoint is
not yet loaded.
"
So it would seem that the line you're adding the breaking point to never gets executed. You can try stepping up line by line through the class to make sure the class is not getting hung up somewhere.
I made a n00b mistake on the IDE. Instead of hitting the debug button, I thought it would work the same as visual studio or eclipse in that I'd have to use the run button, yet when I hit the debug button (That looks like an actual bug) my break-point hit just fine.
I get this same issue intermittently from time to time, I always run the latest version of IDEA. The break points are shown as red but without a tick inside them. Even after I rebuild or re-run in debug they do not get a tick, and they do not "work", i.e., the code continues. I resolve by restarting IDEA, then restarting the debugger/debug run config.
The same happened with me on Mac machine. I followed these steps and all worked fine:
Stop server.
Close all intellij projects.
Open only the specific intellij project on which my application needs to run.
Start the server in debug mode.
I fixed this by manually deleting all build-related files (for some reason Rebuild did nothing) by running this command at the project's root folder. Note that it does also remove Intellij's temporary configuration files, that are usually not included in git repositories anyway. Replace MODULE with the subfolder containing the module for the project. If you are building an Android app with Android Studio the main module name is usually app.
rm -rf ./local.properties ./.gradle/ ./.idea/ ./MODULE/build/ ./MODULE/out/
Then restart Intellij with the File -> Invalidate Caches / Restart option, wait for the build and indexing to finish, and debugging should start working again.
Rebuild solved my problem.
clean & rebuild
Invalidates caches/restart if necessary
I had the same issue in my mac, tried restarting server, machine, invalidate caches and nothing helped. Then, I noticed when the server is started in debug mode, i didnt see this message:
Connected to the target VM, address: '127.0.0.1:64197', transport: 'socket' and I realized that there could be some problem with the server as such.
Solution:
Created new server using command line "./server create " and then associated this server for run configuration. Now started server in debug mode and I saw above message connected to socket port and I am able to see the tick marks on debug point.
I was also facing this issue and found that my tomcat configuration was not right.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>compile</scope>
</dependency>
The scope tag had value as "provided". Changed it to compile and it worked fine.
Android app configuration was the problem for me. I had minifyEnabled true in debug section inside buildTypes in build.gradle file. I had to change it to minifyEnabled false. This change forced me to set multiDexEnabled true as it states in this post Android gives error "Cannot fit requested classes in a single dex file"
My issue got resolved by just updating the IntelliJ in IntelliJIdea -> Check for updates..
All,
This could be a common bug in the Intellij IDEA debugger instead use the key short cuts
like F8 and F9 etc during the debug steps for [ step over and run to debug next point etc..] and don't rely on the debug console buttons provided in the ide
For some reason we experienced this when we upgraded from java 11 to 17. The fix was to use a SpringBoot configuration and not a maven configuration for run/debug.
For me it was a port problem, I don't know why but I had to go back to port 8082 which I was using for tomcat.
This worked for me:
Make a note of the Java version in the run configuration tab (for me its JDK 9 or later)
Go to File -> Settings -> Search for Java compiler -> set Project Bycode version to the same version that you see in run config.
Stop and rerun debugging.
Run config image
Here is what I did.
My code was within an anonymous class where the
debug point would not get the tick mark.
I extracted the code to a
new instance method of the main container class. Then I was able to set
debug point in the new method.
As shown in the picture above.
You can check whether the breakpoint is disabled, the disabled breakpoint button will be grayed out there.
When building my first Spring Boot app, I discovered that I need to restart my app every time I make a change to a Javascript file in /resources/static/some-file.js
This is very time consuming.
When I move the files to the /webapps/ folder, it works as expected, but the files are not packaged in a JAR. The docs mention this, so I cannot continue this way.
I read all about spring-boot-devtools, and have installed it in my POM, but the hotswapping doesn't seam to be working. I still need to restart the entire app to see a Javascript or CSS file change.
When the app starts, I can see the line LiveReload server is running on port 35729, so spring-boot-devtools must be doing something...
What would be the steps to further investigate what is going wrong?
My guess is that when IntelliJ runs the app, the files are copied, so when I make a change, I'm actually changing the original files and not the ones used by the running app.
PS: I'm using Maven, IntelliJ IDEA 15 and Spring Boot 1.3.3 with the embedded Tomcat server. I'm not sure what command IntelliJ runs to start the app. The IDE is handling this "automatically". Perhaps I need to change my run configuration?
You need to turn on a couple of features in IntelliJ to make this work.
First, there's a project specific setting which you would need to apply on any project you want to use devtools in. Go to Preferences > Compiler and enable "Make project automatically."
The next setting is an IDEA registry setting that applies to all projects.
In macOS (OSX), press Shift+Command+A (Shift+Ctrl+A in Windows)
Type "Registry" in the search box that appears, and select the registry to open it.
Lookup compiler.automake.allow.when.app.running and enable it.
After that, restart your app. You will notice that the project keeps rebuilding with every change you make. When you check out the result in the browser, you will see both static files and code have been updated.
For Windows users the steps are:
1) Go to File->Settings, then to "Build,Execution,Deployment"->Compiler and enable the "Make project automatically" flag.
2) Press Ctrl-Alt-Shift-/ and select "Registry" from the menu that appears. Enable compiler.automake.allow.when.app.running flag.
3) Start/restart the app and observe static content reloading.
For IntelliJ 2021.2 version or above below are steps that you need to follow
Add spring-boot-devtools dependency if not already added.
Enable Build project automatically as shown below
Enable option in Advanced Settings as shown below
On Linux, press:
Ctrl-Alt-Shift-/
For mac users I had to press Command + Shift + A
And restart INTELLIJ after Step1 and Step2 without which the registry option was not appearing.
You can user like bellow:
First Open Preferences.../Settings... -> Build, Execution, Deployment -> Compiler and allow Build project automatically. Image will look like
Second, we change Registry configuration. Press command+shift+A for macOS or if you are using Windows press Ctrl+Shift+A, and search for Registry. enable compiler.automake.allow.when.app.running.Images look like bellow
Registry image look like..
compiler.automake.allow.when.app.running enable image look like
Then Enjoy..
The option is now in Advanced settings:
I have a spring boot application. I use IntelliJ 13.
I want to launch my application in debug mode and debug it. I'm on Windows and I'd like to use shared memory. I would like to just be able to click the debug icon, or a single maven goal, and the application launches in debug mode and the IDE attaches the debugger. This is how I am used to debugging most of my java apps.
However, mixing spring-boot and IntelliJ seems to complicate things. IntelliJ seems to want to connect to the wrong process when I push the green "debug" button and I can't find a way to change the shared memory address that the green 'debug' button's functionality is determined to connect to.
The closest I've come is to add jvmoptions to the maven goal in pom.xml, and then if I add a Remote run configuration, IntelliJ lets me specify a shared memory address that matches what I wrote in the pom. This requires multiple clicks to launch the application and then debug it. It works, in a similar way that using notepad.exe to write code also works. Hence my question.
Is there a 1-step solution using shared memory?
Variation of this question:
Debugging jsp with spring-boot and IntelliJ
However the question and answers are limited to using sockets.
The problem was that IntelliJ was using the Maven goal spring-boot:run as the launch configuration, and trying to debug this causes the debugger to attach to the wrong process.
Setting a new launch configuration of type Application and pointing it at the project's class with the main() method resolves this issue.
Thanks to the commentors for suggesting that this was the way to go about it!
A one click solution (tested on IntelliJ IDEA 14.0.1) using Sockets :
Open Run/Debug Configurations, Add a new Configuration of type Remote
On the Before Lauch panel, add a Run Maven Goal with the command line command:
spring-boot:run "-Drun.jvmArguments=-Xdebug
-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
The suspend=n option is important to avoid the Maven Goal to be locked waiting the debugger to connect.
After that you will be able to just lauch this debug task and your app will be launched and the debugger will be attached.
I have to build a Decision Support System, but dont have much experience in Java. So after I connected to MySql with Eclipse (with Connector/J) eclipse started to mess up my other projects. Now, when i try to run other projects in eclipse (that are not related to MySql, ex. Guessing Game) the following error message apperars:
Launch configuration DocsConnectionPropsHelper references non-existing project MySql connection test.
Can anyone help me to resolve this problem please?
UPDATE. it seems that when i press "RUN" elcipse is not running the project that im working with, but other
Your update indicates the issue is actually running the wrong project. To avoid that you may want to close projects you're not working on (right click them in package explorer and select close).
If you do need multiple projects open then when clicking the run icon (which defaults to re-run whatever was ran last among your open projects) make sure you have open in the editor window something that can be ran (and is from the project you want to run).
Then click the drop down arrow to the right of the icon. This will open up a small menu with options to change your build configurations or how it should run your program (i.e. as an application or on a server).
To solve the problem:
-click right botton on the project package you want to work on (run)
-choose Run As
-choose Run Configurations...
-choose DocsConnectionPropsHelper - if in the Project box you see not correct title just remove it. Also remove anything what is in the Main Class box.
-click Apply
-the best option is to close Eclipse and reopen it to make sure that all the settings were configured
It worked for me. Hopefully it will work for you too.
I usually run a dual-monitor setup, so I have two Eclipse windows open for the same workspace, displaying different files. When I'm debugging and a breakpoint is hit, Eclipse switches to the "Debug" perspective, but it also shows the file/line where the breakpoint is in both of my windows. This occurs even if the file containing the breakpoint was open in one window but not the other (before the breakpoint was hit).
This is really annoying.
How can I have Eclipse only show the file containing the breakpoint in one window? Ideally, it would choose which window based on where the file is open already. If it's not already open somewhere, I don't really care which window it pops up in.
You can create another workspace and in that workspace create a new project from the same src code (same files in file system) of the one in your current project in your current workspace.
That would let you stop on one breakpoint without the other window stopping their too.
Notice that after you make some code modifications in one project you'd have to refresh the other project for those changes to apply in it.
Eclipse switches to the debug perspective for all windows the debug perspective has been opened once (i.e. the little icon on the right top corner is available). If you close that perspective (switch to another perspective is not sufficient), it won't switch to it anymore on that window.
At least, that's the behaviour I observed on Kepler (I know, that question is older but just came across, maybe it still helps someone).
This worked for me:
In Window->Preferences->Run/Debug->Launching->Launch Configurations enable "Apply window working set(s)"
Personally I find this more efficient than creating two workspaces.
Closing the Debug perspective (righ-click on the little icon on the right top corner) worked for me.
I'm using Oxygen and I have the following settings in the Run/Debug Preferences:
Open the associated perspective when launching: Never
Open the associated perspective when an application suspends: Prompt
Maybe you select the sources for Debugging by "File System Directory" instead of by "Java Project". To change this go to Run=>Debug Configuration=>Add Sources=Button: ADD...=>Java Project and select your Projects.
Make sure, that the added sources are found first by moving them to the top.
To disable multiple debugging in multiple windows in eclipse, go to Windows > Preferences > Run/Debug and uncheck Activate the debug view when a breakpoint is hit