This question already has answers here:
Eclipse Debugging - Stopping without a breakpoint [closed]
(3 answers)
Closed 7 years ago.
I am trying to debug a program written in Java. I used breakpoints to solve my program issues and I solved some of them and removed the breakpoints after that. Now every time I run the debugger it stops the program in a place that used to be a breakpoint (not any more), and because I have iterative program it takes me so much time to pass these let's say invisible breakpoints in debugger and reach the real breakpoints. I tried to put breakpoints and removed then,nothing changed. It happens only for some of removed breakpoints not all of them.
Any idea would be appreciated.
I am using :
Eclipse Version: 4.2.2
Build id: M20130204-1200
Java vesrion: 1.7.0_40-b43
Update:
Run->Remove All Breakpoints worked for me.
Make sure your java classes and war/ear/jar are in sync. To be on the safe side, delete the war/ear/jar, rebuild & deploy, this should resolve your issue
Related
I am running unit tests on java code using intelliJ and junit. The unit tests were working fine, and they still are . . . until I run in debug mode. Today, when I run in debug mode, all of a sudden, they start iterating through java files that are installed with java, I didn't write, and that I don't have permission for like the following:
This is part of the java code base that I don't have any control over and I didn't set any breakpoint here. Yet it pauses here and makes me click through it to get past it. I wouldn't care if this was only a couple of additional clicks to click through, but I have clicked like 50 times and it still keeps going through base java code that I have no control over and is not what is throwing any problem or issue.
I tried changing the settings for code coverage but that didn't seem to do anything. Is there any way to get junit to only stop at breakpoints that I, myself, specified? Any help here would be appreciated. I didn't see a similar question on Stack Overflow and the stuff on other sites is all about crafting the unit test itself.
So crazy coder (see above) was correct, but I thought I would add (after painfully trying every other alternative) that you have to go to: Run | View Breakpoints and then scroll all the way down on the left side panel (which you may not notice if you have tons of breakpoints like I did) and at the bottom there are breakpoints for Java exceptions. You need to click those OFF see below:
This question already has answers here:
Totally Confused with java.exe
(3 answers)
How is JNI_CreateJavaVM invoked when running a java app from the command line
(1 answer)
Closed 1 year ago.
My question is regarding the java executable, the one that you use to run a Java program and that on Linux it is found for example in /usr/bin/java.
I have been experimenting a bit as I want to look into how everything happens behind the scenes, like how does the bytecode gets loaded, how is the execution of the actual Java program starting and other details that may not be so straightforward.
Until now I have looked at the execution with strace and found that a new thread is created and that thread is the one on which the Java program actually gets executed (from another question that I posted). From what I understand the java executable is a launcher of some sort, but I do not understand all the operations that happen behind the scenes.
So, what exactly is the java executable and is there any place where I can find the source code for it (this would really help me)?
The primary source file for the launcher in the current development JDK can be found here: https://github.com/openjdk/jdk/blob/master/src/java.base/share/native/libjli/java.c
As you see, it's quite short and delegates most of the work to other pieces of code, but should be useful as a starting point.
If you want to see the source for other JDK versions (this is basically the main development repo for future Java versions), you need to look into the appropriate repository.
This question already has answers here:
How to modify Java code while running in debug mode?
(4 answers)
Closed 7 years ago.
I am debugging my application in Eclipse. Finally I reached a breakpoint in a state which will trigger the bug in the next line of code.
Due to a breaking change in the class, the most likely solution would be to remove that line of code.
Of course I could do that now: remove the line, recompile and reproduce the sitatuation again. However, since it is hard to reproduce the bug, can I simply skip the execution of that line of code now? E.g. can I set the "instruction pointer" in Eclipse?
Things I did:
I don't want F6 (Step Over), since that will execute the line.
Also "Run to cursor" is not what I want, since that will also execute the problematic line.
Comment out the code according to How to modify Java code during debugging, but that re-executed the method, thus changing the state
I have tried to find an answer on this question, but I don't only want to run a single line of code but all the rest.
This question only has answers which run code in between.
The drop to frame feature is also not helpful.
The linked questions are from 2009 to 2013, so I hope to get new answers.
I'm using Eclipse 4.5.1 (Mars.1), latest official version at the time of asking.
If you want execute the line after the one you want to skip. When you reach the line before the line to be skipped, select the code and right click, choose Inspect from menu. This will execute the selected code and provide you the result in a popup.
If you know the lines that have to be skipped. you can put them in an if statement and change the value of the boolean in the variables view in eclipse. And then proceed to other lines.
(using code from comments)
if (skipped){
//yourcode
};
It is also possible to create expressions in eclipse.
One thing which I missed out was eclipse also supports hot code swap. You can comment out the line and save it. It will drop the debugger control back to the starting of the method. Hot deploy has supported the code changes in the method implementation only. If you add a new class or a new method, restart is still required. If you have the server in eclispe, here is how you can make that possible http://www.mkyong.com/eclipse/how-to-configure-hot-deploy-in-eclipse/
This question already has answers here:
How to detect if a graphical interface is supported?
(5 answers)
Closed 8 years ago.
Update: as marked duplicate, I just want to mention, this seems like a duplicate, but the answer to the other mentioned question is not completely correct. Instead refer to the accepted answer below.
isHeadless would return unexpected true in certain cases.
Its a bit weird situation, but recently I build a very simple java application which can be run in console/terminal mode or in JavaFX UI mode.
However, then while using it on a remote computer which doesn't have any display attached. I got an error that this JavaFX UI application can't be initiated on systems without display, which is pretty obvious.
To overcome this problem, I have been looking for a robust way of detecting if the system has any display attached and it can initiate a JavaFX application, which has to be a platform independent solution, since it could be Windows or Ubuntu/Linux or Mac system.
Structure of the application:
A Main console app, which depending on input arguments executes internally a console app or UI app.
So that, if any arguments given, run in console mode or if no arguments then run in UI mode.
This is where I want to detect if there is a display available from within my main console app, which then won't even try to run the UI app if display is missing.
Any idea how can we achieve this or suggestion in a proper direction would be great.
I think you could use java.awt.GraphicsEnvironment
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
which will return an array with all the available screens. If this array is empty, there is no monitor.
Edit: About using isHeadless(), you can look at How to determine if GraphicsEnvironment exists
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Determine if a java application is in debug mode in Eclipse
I can start a java program in eclipse by run as or debug as.
Is there any way in the java code to check if it was started by run or debug? I want to do something(e.g. reloading resource) when it's in debug mode only.
Is really eclipse who does the magic, by launching the jvm in debug mode which opens a tcp port to attach a debugger so, if you wish to check if you're in debug mode you'd probably want to check if that port is taking connections, at least is one way I can think of.