Intellij show warnings as errors - java

A feature I like in eclipse the most is that it easily shows me all my errors and warnings in the code (in a list)
Also - by each file there is a mark whether the file has warnings/errors
In Intellij I found it rather challenging...
So for all the Intellij experts out there -
Is there a way so show warnings in a list (I saw something similar in the messages toolbar but it dissapears when there are no compilation errors)
How can I see if a file has warnings without looking into it's contents?
Thanks!

Also I like error/warning list that appears when trying to commit file into Subversion. If any errors or warnings present in file, IDEA shows popup window with Review button. This button opens Message sub-window with very handy and good-looking errors/warnings list.
P.S. Also may be helpful Build -> Rebuild Project
P.S.2. Also see about displaying warnings here: Warnings in IntelliJ IDEA v12

I think what you're looking for is "Inspect Code" under the "Analyze" menu. It allows you to specify which inspections you want to run (called an Inspection Profile) and on what set of files, and puts them all in a window to let you look through them and resolve them.
See Code Inspection in the documentation for more information.

If you do build->rebuild project in IntelliJ, the messages tab (usually at the bottom) should show all the warnings. They should not disappear anywhere even after compiler has finished. If they do, check you have not enabled the "hide warnings" icon on the messages tab.
I guess the difference with Eclipse is due to Eclipse always running the background compiler and also collecting the warnings. IntelliJ runs its own parser and highlights errors in the source tree, haven't really needed the warnings to be displayed always so not sure how to do that.

Related

Eclipse problems view not showing warnings

I have a very similar problem to these threads: Eclipse Problems View not showing Errors anymore and Eclipse Problems View doesn't show Errors
However, my problem is that warnings are not showing up any longer, instead of errors. Errors show up just fine. They aren't showing up in files either. I tried the solutions in that thread anyways, but no luck.
I even tried going to Configure Contents and added a configuration to show everything with severity of "Warning". I tried moving the project to another computer, and warnings showed up just fine. I tried re-installing Eclipse, and the same issue appeared. Any other ideas?
This could be a problem with the Java compiler settings where you describe whether each kind compile issue (e.g. local value not read, etc.) is to be treated as an error, warning or simple ignored.
Go to Preferences -> Java -> Compiler -> Errors/Warnings and confirm that the warnings you expect to be flagged are in fact configured to be warnings.

How to view the list of compile errors in IntelliJ?

I am looking for a way to view all compile errors in IntelliJ, similar to how they are displayed in Eclipse. I tried searching here and Google but have not really found a solution. I really like IntelliJ, I recently converted to it from Eclipse, and I hope this is just something I am missing and not a fundamental deficiency.
I think this comes closest to what you wish:
(From IntelliJ IDEA Q&A for Eclipse Users):
The above can be combined with a recently introduced option in Compiler settings to get a view very similar to that of Eclipse.
Things to do:
Switch to 'Problems' view in the Project pane:
Enable the setting to compile the project automatically :
Finally, look at the Problems view:
Here is a comparison of what the same project (with a compilation error) looks like in Intellij IDEA 13.xx and Eclipse Kepler:
Relevant Links:
The maven project shown above : https://github.com/ajorpheus/CompileTimeErrors
FAQ For 'Eclipse Mode' / 'Automatically Compile' a project : http://devnet.jetbrains.com/docs/DOC-1122
A more up to date answer for anyone else who comes across this:
(from https://www.jetbrains.com/help/idea/eclipse.html, §Auto-compilation; click for screenshots)
Compile automatically:
To enable automatic compilation, navigate to Settings/Preferences | Build, Execution, Deployment | Compiler and select the Build project automatically option
Show all errors in one place:
The Problems tool window appears if the Make project automatically option is enabled in the Compiler settings. It shows a list of problems that were detected on project compilation.
Use the Eclipse compiler:
This is actually bundled in IntelliJ. It gives much more useful error messages, in my opinion, and, according to this blog, it's much faster since it was designed to run in the background of an IDE and uses incremental compilation.
While Eclipse uses its own compiler, IntelliJ IDEA uses the javac compiler bundled with the project JDK. If you must use the Eclipse compiler, navigate to Settings/Preferences | Build, Execution, Deployment | Compiler | Java Compiler and select it...
The biggest difference between the Eclipse and javac compilers is that the Eclipse compiler is more tolerant to errors, and sometimes lets you run code that doesn't compile.
On my system (IntelliJ Idea 2017.2.5), it was not sufficient to enable "Make Project Automatically". I also had to use the menu item "View, Tool Windows, Problems" to see the problems tool window at the bottom of the screen.
You should disable Power Save Mode
For me I clicked over this button
then disable Power Save Mode
the "problem view" mentioned in previous answers was helpful, but i saw it didn't catch all the errors in project. After running application, it began populating other classes that had issues but didn't appear at first in that problems view.
I my case I didn't set Source Root at the src folder. I make a typo to set as Resources Root. after fix it by right click at src folder > Mark Directory as > Source Root, the compile error shows.

Eclipse Kepler shows error marks on warnings

I've got a problem with Eclipse Kepler. In my Java project i've got some warnings and now they are shown as error marks (red crosses) in the project explorer.
It looks like this picture http://i.stack.imgur.com/H8j7f.png
So my question is:
Is it possible to switch it back to the yellow cross for warnings and red cross for errors?
I haven't found anything about it, so I hope you can help me.
Edit:
I've made a test project, and here is a screenshot:
Thanks!
It might me because you set the compiler to mark as errors what used to be a warning. You can set this in the Window->Preference menu. So open it and go into Java->Compiler->ErrorsWarnings and check if everything is like you want it to be.
You can also check into the compiler menu (Java->Compiler) if the java Compiler compliance level is set as you want it to be as #Chrylis suggested.
Otherwise it might be because your program is unable to compile because of a dependency problem then you might want to check your build path or JRE in the Run configurations menu.
Right click on your project -> Run as -> Run Configurations.
I solved it :)
At the first start I took my old workspace as workspace. Because of that there was an Error "Missing Action set" (I've found the "error log"-window :) ) and thats why the red crosses has been shown.
Now I have a new workspace and now everything is fine!

Add Java Exception Breakpoint does not show any matches in Eclipse

When I try to add a Java Exception Breakpoint, I get a blank white screen with no "Matching items:" At the bottom I don't have a package symbol. Is there any way I can configure Eclipse so I can add a breakpoint corresponding to a Java Exception? I am remote debugging.
I have experienced the same behaviour. The build works otherwise fine, and JDK is in the build path. Eclipse Kepler SR 1, Windows 7.
For me, the dialog started to work when I went to Run -> Debug Configurations -> [my debug configuration] -> source tab and added [myjdkpath]/jre/lib/rt.jar there manually. After doing that, the other exceptions appeared as well.
When I removed it again after adding, I was still able to see all my exceptions like supposed to. I guess you can just add any library there, debug, and remove it for Eclipse to "refresh" itself.
For me the cause was that the nature of the project the .target file resided in lacked a Java nature, that is it was just a 'Generic' project.
Open the normally hidden .project file and modify the <natures> section by adding the java nature as in the snippet below then re-open your project.
...
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
...
When I open up the "Add Java Exception breakpoint" dialog window, there is already "Exception" displayed in the input field and all exceptions eclipse knows are listed.
You should type in the name of the exception into the input field. If you don't know the exact name you should write lower-case and you can use "*" as a wildcard.
Then the types matching that name should occur in the list and you can choose them for your breakpoints.
Be aware that these special breakpoints may slow down the debugged process signifiantly. So don't forget to remove them after debugging. This is a lesson I learned the hard way. ;)
I had this problem with Eclipse Neon and JDK 1.8u131. I had created a new workspace and imported only Maven projects. When I tried to add an exception breakpoint, the Matching items area were blank.
The currently accepted answer of "adding the JDK's rt.jar" did not fix the problem for me.
What did work is the following:
Find a "runnable" Java class in one of the imported Maven projects; runnable meaning: a class with a main() method.
Right-click on the "runnable" class
From the right-click menu, select Run As->Java Application.
Eclipse kicks off an index operation.
Click on the Debug perspective and click on the Breakpoints view's Add Java Exception Breakpoint toolbar icon.
Eclipse displays exceptions in the Matching items area populated normally.
The specific version of Eclipse on which I had this problem is:
Eclipse Java EE IDE for Web Developers.
Version: Neon.2 Release (4.6.2)
Build id: 20161208-0600
Windows 10 64-bit anniversary update

Removing warning icons from Java file and packages in Eclipse project explorer

I used to use IntelliJ, the warning icons in the eclipse project explorers are kind of distracting me what I am doing. Is there any way to disable these warnings from package and class names? But the validation should not be disabled, just only from project explorer.
This is, the warnings should be only in the editor. I think this also increases the performance of Eclipse by avoiding extra calculations.
This is how Intellij IDEA works with warnings.
Go to Window > Preferences > Validation and disable validation for whatever types of files you want.
Edit: Hmm. There's also Window > Appearance > Label Decorations, but that didn't seem to disable the decorations in the explorer view.
There is nothing available to hide the problem markers in the explorer view (and no, that doesn't cost any performance overhead as markers are persistent and can directly be queried for each resource).
One (bad) workaround would be to use the Navigator view instead, but that one really only shows the file and folder structure, so the package layout and similar Java specific things are gone then.
Also, in a typical Eclipse setup, your icons will not only be overlayed by the warnings indicator, but also by SCM overlay, project type overlay, disabled optional compiler warnings overlay and a multitude of other overlays. You should get used to this.
go to Windows-show view-other-Problem.
now open the Problems tab which is in the lower screen, in this tab you can see all errors and warnings your project had.
If the problem in the build path, open the build path and remove the JREs which have warning or error and delete them, then import them one more time by import external JREs.
Remember that before you run the project to make a clean from project tab.
OR you can from the problems tab to right click at the warning and choose Quick fix, sometimes this work.
If that not sussced please inform me to found the another solution.
You can also use #SuppressWarnings annotations to be more selective about which warnings you want to suppress.

Categories