Eclipse: stop code from running (java)

JavaEclipseJvm

Java Problem Overview


Sometimes, I'll run a program that accidentally contains an infinite loop or something. Eclipse will let me continue editing the program, but be super slow. How can I stop it? (Do I want to restart the JVM?) Restarting eclipse itself always works, but that breaks my workflow.

Java Solutions


Solution 1 - Java

Open the Console view, locate the console for your running app and hit the Big Red Button.

Alternatively if you open the Debug perspective you will see all running apps in (by default) the top left. You can select the one that's causing you grief and once again hit the Big Red Button.enter image description here

Solution 2 - Java

For newer versions of Eclipse:

  1. open the Debug perspective (Window > Open Perspective > Debug)

  2. select process in Devices list (bottom right)

  3. Hit Stop button (top right of Devices pane)

Solution 3 - Java

I have a .bat file on my quick task bar (windows) with:

taskkill /F /IM java.exe

It's very quick, but it may not be good in many situations!

Solution 4 - Java

The easiest way to do this is to click on the Terminate button(red square) in the console:

enter image description here

Solution 5 - Java

For Eclipse: menu bar-> window -> show view then find "debug" option if not in list then select other ...

new window will open and then search using keyword "debug" -> select debug from list

it will added near console tab. use debug tab to terminate and remove previous executions. ( right clicking on executing process will show you many option including terminate)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNick HeinerView Question on Stackoverflow
Solution 1 - JavaSCdFView Answer on Stackoverflow
Solution 2 - JavaSnowcrashView Answer on Stackoverflow
Solution 3 - JavaOliveiraView Answer on Stackoverflow
Solution 4 - JavaTiaView Answer on Stackoverflow
Solution 5 - JavaHari KanureView Answer on Stackoverflow