IntelliJ IDEA: How to display warnings in the project tree? - java

I recently moved from Eclipse to IntelliJ and I was really used to see any kind of warnings in the tree of my project in eclipse.
I think in IntelliJ by default compilation errors are displayed in the project tree or maybe it worked by enabling the "build project automatically" setting. But I did't find any way to enable the same for simple warnings (e.g. unused imports).
Does somebody know how I could achieve this or anything similar to it so I can simple get informed about any warnings?
I would be happy about any help I can get

Most inspections run in the background only for the currently open file for the performance reasons, therefore there is no way to mark the files with inspection warnings in the project view.
Use Analyze | Inspect Code to get the list of the files with warnings.

Related

IntelliJ strange behavior

I've installed 30 day trial of IntelliJ 15.0.2 and cloned my project using git (I've created this project in community version). Project compiles (maven), runs, works. But new IntelliJ does not underline my errors, misspellings etc. When I wanted to commit, IntelliJ shows big number of errors, mostly on imports, as it can't resolve them. All dependencies are inside pom.xml. Once again, there were no errors in community version of IntelliJ. Ultimate version builds project just fine, but doesn't underline any errors and shows almost every import as unsolvable. What could go wrong? How to fix it?
Go to Build -> Make Project. After that errors should be visible in the project tree and in the specific project files.
You may need to mark the source dir, by right-clicking it on the project tab and select mark directory as -> source root
Check that you have a correct project sdk set in modules configuration. If IJ doesn't found any classes, jdk classes included, probably there is no sdk set.
You can also try to invalidate caches (in File menu) and rebuild project
I have faced with strange behaviour of Intelij Idea after update (syntax highlight stopped working). If you want to understand what is going on with yor Idea and can not quickly find an answer in internet, just go to Log files (for Mac OS the path is
~/Library/Logs/IntelliJIdea< your version>
List all files in that directory
ls -la
in terminal and find the latest one. Usually it should be idea.log (without numbers, logs with numbers identify logs for previous days). View that log. If that log contains a lot of ERRORS, try to find the reason (you can just type
grep "ERROR" idea.log
in terminal to find all lines that contain errors). Usually log files shouldn't contain errors, just info and warnings.
In my case syntax highlight stopped working. The log looked like
You can see here that error is in plugins that called like haxe.
I found that plugin in my idea, uninstalled it and idea started working properly. I investigated the log after and what I have seen there:
You can see just INFO in new rows.
Investigating a log can be really useful if you can not find the rootcase of your problem quickly in the internet. I hope it can help you even if it can be quite tricky.
Good luck!

Sudden weird errors on a project

Today I came to work, happy. But when I opened my Eclipse, I saw that one of my projects has errors.It's weird because it shows that it has errors only in the window bar, and not in the Navigator. I don't have any Java errors, this is a valid project that was fine all the time:
Some of the errors on the error log of Eclipse:
JavaBuilder handling ImageBuilderInternalException while building: SP_Procedure
Cannot connect to VM
File <SomeFile> has been skipped, problem while reading ('Resource is out of sync with the file system')
Unhandled event loop exception
Internal error
When I run an application from this project, I get a warning message but when I proceed, it works fine, but still. It's very disturbing and I'm not sure if it's harmless.
I tried to:
Restart Eclipse
Restart my machine
Clean projects and recompiling them.
Refresh projects
Pray
Nothing helped. What could be the problem? (I'm using Indigo Service Release 2)
The following nuclear option has desperation written all over it. But I have been where the OP has been with the Juno version of Eclipse.
Run a "Synchronize with Repository" and save all of your local updates to a different directory.
Delete the project. (Check the box to delete the contents on disk. Scary step, but that's OK, because you saved it in a different directory in the previous step, right?)
Read in a fresh project from the repository. It builds happily at this point.
Integrate your local updates.
Keep on praying.
Looks that one unused JAR was deleted, but for some reason, I didn't get errors in any file, even in the files that imports this JAR! So what I did was restoring this JAR, delete unused imports and deleted the JAR again.
I've found this error after two days of navigating on this project on each file.. This is weird that Eclipse didn't recognize that1 this is an error, and throw many unrelated errors such as:
Cannot connect to VM
File has been skipped, problem while reading ('Resource is out of sync with the file system')
Unhandled event loop exception
Is this a bug in Eclipse? (All errors and warnings are enabled!)
1 As seen in the image in the question..
A class from the list of imports for the file seems to have moved out or the jar file containing the class is missing.
Expand the imports section and check if you find some classes that are missing but have been imported.
Though it is a pain, sometimes the easiest solution is to back up all your projects (either in a repository or somewhere else on your computer) then uninstall and reinstall eclipse. No it's not fun, but it should reset eclipse so everything works again. The downfall though is that you have to reconfigure eclipse to any special settings you had/reinatall any extra functionality currently installed (eg. android add-on) and reconnect to any repositories you have. While punting isn't fun, it can be effective... I hope you don't have to resort to this though.
I have went through that problem a lot of times, and tried everything you tried. Rebuild, recompile, refresh, remove and add JDK, remove and reinstall Eclipse... nothing worked
The only thing I concluded is that the workspace metadata was corrupted.
What I did (every time it happened) was
Create an empty workspace
Import -> existing projects into worskpace
Mark the "copy projects" (else it will only link them)
Wait for the copy, and start working with the new workspace
If you work with SCM systems (Git, SVN, etc), making a full checkout will do the trick too, but the worskpace import will let you retrieve those changes you didn't get to commit (if any).
It's a little painful if you have somethings already set (like JDK names, servers, etc), but then I realized it was faster than keep searching how to fix the workspace
Regards!
PS : I've been working with Kepler lately, and everything works fine till now
Click Window -> Show View -> Other -> General -> Problems
This view will show you what is wrong.
Did you, by any chance, update your virtual machine outside of Eclipse? I can't help but feel that we're both missing a finer detail here. I just keep seeing "cannot connect to VM" and thinking that it's a major clue.
Have you tried running anything from the terminal? Does it work there?
If so, do you know where your current edition of Java is located? Is Eclipse looking somewhere else?
Is this exclusive to one project? Do you use any additional libraries to the JDK?
Maybe try this for Resource is out of sync with the file system error:
Right click project in Eclipse Package Explorer
Close Project.
Right click project in Eclipse Package Explorer
Open Project.
Other things not mentioned:
project properties > java build path, see if any of those tabs got changed, local file got moved? read/write permissions on some file you are linking to?
project properties > java compiler, see if workplace settings have changed? maybe under errors/warnings, you can systematically set them to 'ignore' until the error goes away to determine what type of error it is?
maybe update some of the eclipse plugins?
I saw something like this happening for a number of reasons. Mainly because of validation in files other Java source code. See if you are validating XML for instance.
Right click your project and chose Properties (Alt+Enter) and Validation to see the related configuration.
As for the danger, I lived with those marks for ages and nothing wrong ever happened.

Eclipse code completion automatic deactivation

Whenever I run Eclipse, it suddenly deactivates some completions tags (but not all) with no reason. This happens always during, when I write some code. At the start of Eclipse, everything is okay but after a while this problem occurs. Every time I solve this by resetting the preferences and restarting Eclipse. But it takes too much time and annoys me.
Is there a special Hot-Key to (de)activate some completions tags?
I would bet on a plugin malfunction. Try to reinstall Eclipse from scratch without any custom plugins, and add only what you need, then add them one by one until you run into this problem.
Alternatively, open Eclipse->preferences->install/update->unintsall or update (link)->configuration->view error log and see if you get any exceptions on any plugins, if you identify something fishy, uninstall that plugin.
In my case the Eclipse Preferences named Type Filters (under Java | Appearance) seemed to cause that experience. We had excluded all common root package names (com., org., sun.), but also java. and javax.*. After deaktivating those entries in the "Filter list" Eclipse's Ctrl-Space again provides the missed proposals.

IntelliJ. Debug a program even if it does not compile

I have a Java project in IntelliJ that compiles, and now I am slowly changing.
Is there a way to ask IntelliJ to run the project, even if some parts of the code still do not compile? If so, how?
Why I would need this, you ask? see this ticket:
IDEA-61945 Run and Debug commands should ignore compile errors not related to the main being run.
http://youtrack.jetbrains.net/issue/IDEA-61945?query=it#tab=Comments
Please, do not answer this post questioning whether I should or I should not need to run a project even if it does not compile. please.
If not possible in IntelliJ, is it possible in maven? How?
In Intellij 12 you also have the following option (which personally I find the best one):
Go to Edit configuration of your launcher
Go to the before launch section
If 'Make' is in the list: remove it
Add 'Make, no error check'
Now, when you run, a make will still be done automatically but the run will continue even if the are compilation errors.
Regarding the above debate; I think it makes perfect sense to be able to run a part of the code that does compile even if another part of the code does not not; e.g. if that other part of the code belongs to a module that is in your project but not involved when running.
I ran into this exact same problem at work today. Before now, I probably would have been quick to jump on the bandwagon of, "Why would you ever want to do that?" Turns out that Eclipse lets you do exactly this, and if you start working concurrently with other developers who depend on this feature (which is to say, check in code that doesn't compile), it's handy to be able to do the same in IDEA!
And lucky for us IDEA users, you can. Follow these instructions from the FAQ for Eclipse Users, and you're good to go:
To be able to run code with errors, you can select the Eclipse
compiler in Settings dialog, Compiler, Java Compiler and add the
-proceedOnError option to the Additional command line parameters for the compiler.
The only thing that's lame is that it's not quite as seamless as in Eclipse. First, you'll have to untick the option to Make before run because IDEA won't run if make fails. Then, you'll have to remember to build before running. With those caveats, though, you should be able to accomplish what you're after.
Stijn Geukens's answer is correct, but it can be improved.
In Intellij Idea version 12 instead of removing the "Make" rule it can be replaced with "Make, no error check". This way project will be rebuilt (compiler will atempt to do it), but it will run the program independently of compile outcome.
If you want to debug just one part, then you can create a unit test around that. If you do not use the class that does not compile, then you can still debug the unit test related code.
When there are compilation errors, you can exclude specific files from compilation.
Go to the Messages window (if it is not visible: View -> Tool Windows
-> Messages)
Right click the problem file
Exclude from compile
At least in Intellij 12 you can achieve this.
First try to compile the project, including the broken class(es).
Then in the Messages view, containing all the compile errors:
Right-click the class you want to exclude
Click 'exclude from compile'
See this question on how to reinclude afterwards.
For Intellij 2017.3.1 my configuration is like this:
Use the Eclipse Compiler: Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Use compiler: Eclipse
Select "Proceed on errors"
Edit your desired configuration defaults (I use this for JUnit) before launch to Build, no error check: Check this screenshot
Additional step in order for Intellij not to open the classes with errors when you run your configuration. Un-select Automatically show first error in editor in Settings -> Build, Execution, Deployment -> Compiler
PS: This configuration is not perfect for all usages. It only works when you are fixing unit tests that were failing because of your changes in implementation code. When you go back to implementing features it is more useful to disable this feature since it will let you run you implementation code with errors and it will not jump to compilation errors. You need to go back and forth with changing the Eclipse compiler with the Javac one for best results.
Wow, it's been a while since I've been in IntelliJ and I miss it dearly! From my recollection you should be able to right click the main method in a module and run it directly so long as the remainder of the files in the module compile. I don't think it matters that a second module in the same project has errors. Is that not working for you?
updating for version 2017 - 2.5 community as menu options are slightly different
Navigate to:
Run>Edit Configurations
near the bottom of the Run/debug config window look for
"before launch: Activate tool window "
the field below this heading lists your current build config settings.
Use the + and - symbols in order to add and remove build preferences.
Once completed
Select apply then Okay
Thats it!
I don't think its possible at all. How you can run something that doesn't compile? That would be like driving a car that isn't put together. You could comment out the files that don't compile, so that the project compiles....
Edit -- or you can have Intellij not count the file as source by
Right Click on your project -> open module settings -> select your module -> select the file -> excluded

Errors in Eclipse for no reason

I'm building an Android app.
I worked today on my app, and suddenly I saw that all the projects in the workspace are marked with an error. I don't know what caused it, and I can't find explanation of the error anywhere.
I'm using Helios with Windows 7. I even tried downloading Eclipse again but it didn't help.
Today I tried to integrate Facebook with my app. Their tutorial required me to try to get a hesh key from a keystore. In the process I added an Environment Variable named JAVA_HOME, and pointed it to the JDK.
I don't know if it's the cause of my problem, but I think it might be related.
I really don't know what to do.
Thanks!
Try this. In eclipse, go to Project --> Clean --> Select "clean all projects". This should rebuild all projects.
Try cleaning your android project. I get problems with Eclipse sometime, and if I clean the project, it fixes it.
Find the "Problems" view. That will give you more details. Post the description of the problems, we can get more information.
click Window -> Show View -> Problems
Typically, the problem is with a resource you've recently added to your project (drawable, assets, raw, etc.)
Some things to check are:
Invalid XML files
Invalid 9-patch images (outer 1-pixel border must be full black or transparent)
Typically, just start by removing a resource, then cleaning your project (Project > Clean). If the errors go away, that resource is your problem. If not, continue this process until the error DOES go away. Start with the most recent resources you've added, naturally.
i solved error or all project showing errors this way.... close eclipse.
then Right Click on eclipse shortcut-->open file location-->open command widows there and type "eclipse.exe -clean" eclipse the starts..and in my case errors were gone...hope it helps

Categories

Resources