netbeans runs program even if there are errors in code - java

so, I accidentally chose "don't show me this message again" and "Run anyways". is there a way to undo this setting? Like there can be typos throughout the program, and it'll still try to run. I don't want this, because if there's a section of code that might not be called while i'm testing the program, I might not notice the error.
newest version, 7.4 NetBeans EE for windows
if a function call is actually made to the "uncompilable source code", then it gives such an error
I can search through the program manually line by line, making sure there are no red squiggly lines, but this seems impractical. perhaps I should just re-install netbeans?

According to multiple posts on the Internet, you should remove the BuildArtifactMapperImpl.properties file in the <netbeans home>/<version>/config/Preferences/org/netbeans/modules/java/source/ directory (where it is depends on your installation).
It should have the askBeforeRunWithErrors property set to false. Some just fixed buy deleting the whole file.
Personally, I do not have that file but I have not checked that option, so it might be generated at that point.

how about you delete the settings file stored in the your user DIR as an xml file. it will reset netbeans bac to defaults. or you can edit it and locate parameter askBeforeRunWithErrors to false as it's set to true.

There is a red stop button in the output window. Click that.
There is a bug in NB forum. And another forum reply says that
Don't bother - found it after making a directory diff :
Simply remove the file
.netbeans/7.0/config/Preferences/org/netbeans/modules/java/source/BuildArtifactMapperImpl.properties

Related

Eclipse Debugger not following the source code

I have encountered a problem with the Eclipse and I am unsure how to fix it. When I enter the debugger and press the step over button the debugger usually highlights the line of source code that I stepped to. However, for some reason this is not working for me anymore. I enter the debugger and go to the breakpoint but if I hit the step button the source is not highlighted and if I continue to hit the step button I can see that the Debugger is stepping into other files (looking at the Thread) but my view of my code doesn't change. The only way I can find what line my Debugger is on is if I control click on the line from Debug tab and click Lookup Source which then highlights the line the Debug Current Construction pointer is on. If I am debugging I would like to follow this Current Construction pointer line by line. I must have accidentally altered this somehow and I am unsure how to change it back.
Simply stated the problem is this, usually the Eclipse Debugger highlights your source code as you step through it. It is not doing that for me anymore, the debugger is stepping properly but it is not highlighting the line of code that it is on.
This happens when we make Java code change in file, compiler creates a class but running server has a old copy of your class file.
Go with JRebel to get rid of such kind of issues.
This can also happen if you have more than one project in you work space, and you create a debug configuration that points at the wrong project base directory.
To resolve this:
Open your debug configuration list (Run -> Debug Configurations)
Select the proper configuration under your Remote Java Application list
Verify that you have the correct project source listed under the Base directory on the Main tab.
If you have the wrong directory selected (say, one that holds a different project), the debugger will start with no issues, but you will not be able to step through your code.
I had the same issue.
There was a workaround for that by right-clicking on associated callstack line in Debug view and selecting "Lookup Source". After that the current instruction line is (green) highlighted as usual. But I needed to do this after every debug step.
Rebuild all projects didn't help.
The solution:
Restart Eclipse and all works fine.

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.

Eclipse edits and saves don't make changes to running program - powercut

So I was busy writing away in eclipse when there was a power cut. Luckily I had been saving regularly and so when I got back on I still had all my work.
However after writing a few lines and running it and spending a while trying to figure out why it wasn't working I realized that whatever I wrote didn't change what ran. I could even comment out bits of code OR EVEN the entire program OR EVEN YET DELETE LINES OF CODE, yet it still runs as if the same code was there from before the power cut. In the file menu all the save features are grayed out, yet if I control S and restart my pc or restart eclipse then it has made changes to the code and saved however the new code has made no effect on anything and still runs as before.
Has anyone else experienced this?
Has eclipse got some auto save feature for problems such as power cuts in order to prevent work less?
Has this put eclipse in a special mode that I can exit back to the normal mode?
When issues like this happen, the first thing to do is to click on Project -> Clean in the main menu.
The Project was corrupt.
Solution
Copying classes across into a new project and deleting old project.
Try restarting eclipse. Perhaps it kept some content in the editor but the link was broken from the actual file that it's building. Maybe copy your code just in case the file is out of sync with the editor.
My problem was the folder was in a different workspace, so the old version of my file was in there, but my newer saved version was in a different workspace. I didn't realize the newer version was somewhere else. This happened because I need to send files back and forth from my main computer to my laptop for school, then return the folder again. So be extra aware of your workspace locations! If you export a project from Eclipse, it will always choose one by default, but you can choose another in the export menu.

Java Debugging: Source not found

I am having a problem with Eclipse where I can run my program just fine, but when I try to start the debugger, I get this message
The picture is a little hard to make out, but instead of getting the normal debugging window, instead it says it is throwing a ClassNotFoundException, and is trying to dislay the source for Launcher$ExtClassLoader.
The thing that really baffles me though is that I can run the code just fine, it is only when I click the debug button that I have the problem.
I have also tried debugging at the command line with JDB, and I got the same error.
So far, I have tried Reinstalling Eclipse and downloading (what I believe to be) the correct Java Development tools for Mac OS X.
I have no idea what else I can try, so any help would be greatly appreciated. Let me know if there is any other information I can provide.
Source not found might be legitimate for dynamically loaded code (e.g. Maven).
There are three workarounds known to me (after months of search):
Connect to a running JVM with the debugger and you will see the code.
Use Dynamic Source Lookup plugin for Eclipse from here:
https://github.com/ifedorenko/com.ifedorenko.m2e.sourcelookup
Use run-jetty-run Maven plugin
http://code.google.com/p/run-jetty-run/
I prefer and recommend 3. It works and starts webapp much faster than jetty:run.
Unfortunately 2. didn't helped me as it has issues with Windows paths with spaces.
I have filled an enhancement request on Eclipse Bugzilla and if you agree this issue "Source not found" should vanish forever, please vote for it here:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=384065
Do you have the sources for the files that you are using. If you are using Maven (M2Eclipse) you could download the sources. This might solve the problem.
Otherwise you could go and manually attach your sources. Here is how you manually attach sources.
Next you have to attach the sources-
Hope this helps
The "source not found" is a red herring - there may simply be no way to get access to the source that is throwing the error, because it is deep in the guts of the debugger's class loader.
The better question, then, is, "Why is scottrice.ChessPuzzles.ChessPuzzleDriver not being found?" The only possibility that occurs to me at the moment is that something might be weird in your debug configuration. Did you debug the program by just right-clicking a file with a main() and choosing "Debug As" -> "Java Application"?

"Uncompilable source code" RuntimeException in netbeans

I'm trying to help another developer who is using Netbeans. When he runs or debugs some code of his in Netbeans (6.9.1) he gets an "Uncompilable source code" RuntimeException. I'm pretty experienced in Java but am more used to IntelliJ, and haven't used Netbeans at all.
I've done it a bit of googling and it seems Netbeans will compile code even with errors, and then throw the RuntimeException at the errors. (Fairly bad behaviour IMO, but I guess some will find it useful.) I've got him to completely rebuild the project with no compile errors, but the RuntimeException seems to still occur. I assume he's got some bad cached class data somewhere deep within Netbeans.
2 questions:
What is the best way to clear the cache so we can find out where the uncompilable code is?
Is there any way of turning off this behaviour so the code won't run/debug unless everything will compile, so these RuntimeException's won't be injected into the code?
I've googled a fair bit, but haven't found the answer to either of these questions yet.
Update: More information:
Turning off the "compile on save" option makes the problem go away. Turning CoS back on again brings the exception back. Unfortunately this isn't a fix, as CoS is a very useful option.
http://netbeans.org/bugzilla/show_bug.cgi?id=182009 seems the closest bug report, but it has been closed as "RESOLVED INCOMPLETE". Unfortunately the bug is hard to reproduce - the exception is happening in Java library code, when it calls a third-party library, so there isn't anything at the point the exception is thrown we can change. And the code will work for weeks, and then suddenly start throwing this error with no obvious reason why.
We've tried manually deleting the entire build directory - still not a fix.
We finally got a solution, but still don't quite know why the situation occurs. When you have Compile On Save activated, Netbeans generates a second set of class files for debugging etc. These are stored in $USER/.netbeans/var/cache/index/s*/java/*/classes
Somehow (not sure how) this directory can get corrupted or fail to update.
If you close netbeans, delete $USER/.netbeans/var/cache/index and all subdirectories and restart netbeans this clears the cache. If you have no compile errors, your problem ought to go away at this point.
NB: $USER is your user directory - on Windows 7 this is usually c:\Users\username, I guess on Unix it will be ~username.
If you get this problem please vote for, comment on, or add information to: http://netbeans.org/bugzilla/show_bug.cgi?id=182009
I experienced the same wired problem in NB 7.0.1, my hammer-IQ solution was to make a typo in the source code, run NB with this error (despite an error message) and than the cached class was successfully deleted.
I experienced this issue on Linux Mint Nadia with Netbeans 7.2.1, but was stumped as to where the cache location might be - mine was actually located at
/home/USER/.cache/netbeans/7.2.1
rather than in the .netbeans folder.
If you're not sure where the cache is located on your particular setup, just go to the help > about menu in Netbeans and it'll tell you the correct path.
After realising that the cause was a bad cache from the other posted solutions, I solved this problem by copying the file to another directory, deleting it from NetBeans, and then adding it again.
In fact, you neednt delete whole of index folder.
When you open netbeans and your project folder is active. Netbeans starts scanning files and creates temporary project folders (in index folder) for all active projects. If you check index\segments file(its a text file and can be viewed in notepad/(text editor)), you will be able to identify the folders that represent your project. You can then delete those folders and restart netbeans.
*Active project means those projects that were open before Netbeans was shutdown.
Had the same problem on Windows 7 with Netbeans 12.
Cache is here:
C:\Users\<Username>\AppData\Local\NetBeans\Cache
, but the deleting cache is not helpful sometimes. The better solution is to recompile the problematic class i.e. make a minor change (e.g. add space) and save.

Categories

Resources