Stop eclipse switch to Debug tab - java

My problem is somewhat like the question here and here, but none of those answer can apply to my situation.
I am running tomcat inside Eclipse, and my project has some quartz job that run by schedule. Those quartz job meets null pointer exception very often (since they must parse documents from an untrusted source) and surely the team who are working with those jobs can't fix them right away.
The result is that Eclipse pop up debug tab every now and then, usually take up focus so that I can't look what happen in console. Moreover, when Eclipse meet the exception, it pop out to take focus out of the program I currently work in (browser, email,...). It is very annoying.
Can I simply skip all the null pointer exceptions (since the fail of the jobs doesn't affect my program anyway) or is there a way to keep the focus on the console tab, and keep Eclipse doesn't complain everytime an exception pop out?
I'm very thankful for any possible solution.
UPDATE: I'm using Eclipse Helios with few plugins.

Have you looked in Eclipse's settings under Run/Debug? There are two useful options you can change;
Activate the workbench when a breakpoint is hit
Activate the debug view when a breakpoint is hit
Another obvious option would be to not use debug mode and "run" the application instead (AFAIK, breakpoints will never stop execution when "Running" code instead of "Debugging" it).

Window > Preferences > Run/Debug > Perspectives >
> Open the associated perspective when an application suspsends:
Set to Never, or Prompt (as desired)

It sounds like you have an unwanted Breakpoint set up in your Workspace. Open up your Breakpoints view, and you should see a breakpoint listed as a NullPointerException, RuntimeException or Exception. Uncheck it.
If you want to suspend the thread for all other occurences of NullPointerException, then you could look into Conditional Breakpoints (i.e. right-click on the breakpoint in the BreakPoints view, and click on Properties. You'll see a dialog with options for 'Conditional breakpoints'). That should set you on your way.
Edit: here's another possibility. Try looking in the Java Debug preferences:
Menu > Window > Preferences
Then choose:
Java > Debug
Now uncheck an option called:
Suspend execution on uncaught exceptions

Related

Eclipse debugging : Stack trace on event

Im trying to get the code flow of an open source platform. I have got the source code and ran the program from eclipse. The program has an option called "Run job" and I want to know where the control goes when that option is clicked. How can achieve this?
First, try to identify the control with the label "Run job".
You could do this by searching the source code in Eclipse with Search > File and then setting "Containing Text" to "Run job" and "File name patterns" to "*.java".
Probably in the same file, there is an ActionListener (or similar) added to the control that calls a method, when the control is clicked. This is the method you're looking for. (Add a breakpoint to see the flow in the debugger or try to understand it from the code.)
Apart from searching for the appropriate handlers and buttons in the source code (if you know the names), you can also enable tracing.
In your run configuration, there should be a tab for tracing. There, you'll want to enable some of the options under org.eclipse.ui that start with trace/.
You will get a lot of debug output, and there might be no trace option for the event you'd like to see. However it works well for things like keybindings (trace/keyBindings) and knowing which UI element got an event (trace/graphics). Note that some also take arguments, e.g. a commandId (something like org.eclipse.ui.edit.copy, will depend on your application).
You can find a small help text for each option here.

Java with Eclipse: Debug mode enabled?

I started developing a game in Java with Eclipse. As you all know you have to debug a lot while coding. But I have the following issue:
My game is full-screen. If I run into a breakpoint it stops (like it should) and for some reason I can't switch window anymore (I am using Windows 7). I have to press Ctrl + Alt + Delete" and start the "Task manager" to be able to switch to Eclipse window and continue debugging.
So I tried to use window mode instead of full screen. Now if I run into a breakpoint the Eclipse window gets the focus (automatically) and I can debug easily.
So I thought it would be great to be in window mode, if and only if I am in debug mode, else it should be full screen.
For this I need to know if I am in debug mode or not. After reading this and this it seems like you can't check that easily, cause it depends on the VM you are using. Also it seems like the best solution is to use the Eclipse Debug/Run-Configuration and set a VM or program argument.
But how can I tell Eclipse to use this configuration only for debug mode? Or is there even a better way to determine, if debug is on or off?
It seems like the best way is to use arguments and pass them by using a Debug-Configuration and a Run-Configuration with the right values.
In Eclipse you have the possibility to add a Configuration to the Run list and the Debug list.
This can be done by going to the common tab inside the configurations and check the Debug and/or Run checkbox inside the "Display in favorite menu" section.
You can also edit the favorite list (add/remove/move entries) by clicking "Organize Favorites".
Note, that it does not prevent you from runing the Debug-Configuration or debuging the Run-Configuration.

Eclipse Terminate Keyboard Shortcut

How do I get eclipse to terminate? I use the keyboard shortcut Ctrl+F11 to run a program and I cannot enable the terminate hotkey, since in development I run the program 100s of times per day I waste a lot of time clicking the red terminate square.
I have looked at previous postings of this question and have gone to Windows --> Preferences --> General --> Keys and found "Terminate" command: I have set it to binding Shift+Ctrl+F11 and set the "When" setting to "In Windows". I have tried various other options but the shortcut never works. Why?
Addendum: Unfortunately there is no keyboard shortcut for the Terminate/Disconnect All option mentioned below and you cannot manually set one. But at the very least, you should be able to terminate all launches with just one mouse click with the instructions below. I would consider this a solution to a significant part of your problem, which is wasting a lot of time clicking the red Terminate square.
To terminate all launches:
First Time Setup:
In the menus, click Window > Show View > Other...
Type debug in the search box and select Debug > Debug
Click OK. The Debug pane will open.
Following which, how to terminate all launches:
Open or switch to the Debug pane.
Right-click on any of the items in the pane to get the context menu.
Click Terminate/Disconnect All.
Tips:
If the Console pane is annoying you by opening automatically, either separate the Debug pane from the Console pane (so they don't share the same section) or disable these two buttons in Console pane's toolbar:
Show Console When Standard Out Changes
Show Console When Standard Error Changes
Some of the items in the Debug pane may not enable the option to terminate all. In this case, try right-clicking other items that look different.
Thanks to this SO Q&A, but it wasn't fully clear: Eclipse : How to terminate all applications at once?
Since CTRL + F2 does not work unless you have:
previously activated the debug view and
selected the process that you want to terminate
The best that I can come up with is to use the "Keys" preferences to assign CTRL + SHIFT
+ F2 to "Show View Debug", then you can type the following:
CTRL + SHIFT + F2 (activates the debug view)
DOWN (move cursor down onto the first process)
CTRL + F2 (Terminate)
F12 (activate editing window)
You can basically use Ctrl+F2 to terminate Eclipse.
Use Ctrl+F2 to terminate the current running server, not eclipse.
There is no shortcut key to terminate eclipse.
Try here:
http://www.developersbook.com/eclipse/eclipse-keyboard-shortcuts-2.php
http://eclipse-tools.sourceforge.net/Keyboard_shortcuts_%283.0%29.pdf
Yes you are right. In fact if you check Windows --> Preferences --> Keys --> Terminate, "Terminate and relaunch", it is showing for server, not eclipse.
I think you are looking for this:
Go to Properties -> General -> Keys
Look for "Stop" in my case there are 3, use the one under Category "Launch Bar".
Assign your hotkey and set "In Windows" under the "When" option and apply.
This terminates the running process, even if the hotkey is called "Stop", wich is somewhat confusing, since there is another hotkey called "Terminate".
Regards!
I manage to make it work, binding terminate command to PAUSE key with "when" clause to "In window". It works if in debug, not in run.
Hope it helps

IntelliJ IDEA Multiple Instance

IntelliJ IDEA by default has the functionality to debug/run more than one instance of the same program.
For example; if I run debug on Project X and it's main threads is in waiting, sometimes I come back and run it again as the DEBUG button is not indicating a currently executing session. Nor does IntelliJ stop you from running another session of the same program (Project X)
Why is this functionality necessary, and how can I turn it off?
a) The functionality is very good when you want to rerun a configuration in a new instance.
For example a simple client that you want to start in several instances without any other effort.
b) You cannot really turn it off.
This will start a new Run or Debug session:
This will rerun the current Debug session:
This will show you your current Debug sessions:
You can enable the Single instance only option. To do this,
Go to Edit Configurations... in the dropdown to the left of the Run button.
Select the appropriate configuration.
Click the Single instance only checkbox.

Restart an application in Eclipse

I'm developing a standalone server (not a war) using Eclipse Juno. I run it as a Java application from Eclipse. After I've made some code changes, I want to stop the currently running server and start it up again. I do this tens of times a day.
The way I do that at the moment is as follows:
- Go to the "Debug" tab.
- Select the server process.
- Click on the stop process icon (red square).
- Click on the green arrow to re-run the last run application.
- Go back to the "Java" tab.
Is there a quicker way?
Ideally, I'd like a button or keyboard shortcut that would stop and restart the application in one click. If it doesn't already exist, can I extend Eclipse in some way? Where should I look for an example of something like this?
You can restart running application by right clicking it in debug window and selecting "Terminate and relaunch".
And quickly switching beetween views with Ctrl+F8
Also if you've already terminated the application from console, you can simply hit ctrl + f11
If you really want you can also add custom shortcut for terminating and relaunching by Window -> Preferences -> General -> Keys -> Find "Terminate and Relaunch" and choose your favorite key combination!
Eclipse Neon.1 added a way to terminate before relaunch by holding Shift while clicking on a launch history item.
You can also make that the default behaviour by enabling the option “Terminate and Relaunch while launching” in Preferences › Run/Debug › Launching.
https://www.eclipse.org/eclipse/news/4.6/platform.php#terminate-relaunch-history
I had the exact problem you had. I had a simple Java class with a main method that runs an embedded tomcat.
When I change any of my service classes, I wanted to terminate the current embedded tomcat and relaunch with one single keystroke.
I know, I could have just clicked and done the same with 2 mouse clicks... but... it pained me enough to learn a wee wee bit about Eclipse plugin and threw something together.
Hope this helps you too.
https://bitbucket.org/mantis78/relaunch-plugin/wiki/Home
Simply saying, You can't modify eclipse Like you wants to. But You can follow this procedure to minimize your effort
1. In Eclipse Project TAb-> Check Build Automatically.
2. And After Every Changes You are making Just Run The Project using Green button in eclipse.
Also you Can use CTRL+F11 to run project.

Categories

Resources