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.
Related
When I create a new Java project or open an existing one, IntelliJ doesn’t highlight any of the text nor does it suggest anything. All the code is 1 single color. I’ve marked my src file, made sure power safe is off, made sure highlight is enabled, and even reinstalled IntelliJ CE. I’ve also disabled all plugins. Any suggestions is appreciated.
picture here
Your screenshot shows that the file is not recognized as a java source file.
Go to Preferences -> Editor -> File types
Scroll down in the list of Recognized File Types and click Java.
In the list of registered patterns make sure it shows *.java.
Also ensure the file is not marked in the Ignore files and folders section at the bottom of this preferences panel. Perhaps you added it by accident (with some shortcut).
Also, while reinstalling IntelliJ, you have probably imported your previous settings. With it, you inherited this issue.
If this doesn't help, please share a screenshot of your project/module structure and setup.
Last but not least, try to create the file using the context menu. E.g. try to right click on your src folder and select new and select Java class or Package from the options. Would be good to check anyway, to see if these are valid options. If they do not appear here, it indicates the project setup is erroneous.
Solved! Thanks to #yole I did the following 'make sure that the *.java extension is listed in "Registered patterns" for the Java file type in Settings | Editor | File Types".
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!
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.
i am new to android. In the project most of the images are used, for some reason some of the images are not used.
But all the images are present in the res/drawable's folder. Going through the code to find which images are not used is a time consuming.
How could i check which images had not used anywhere in the project and remove it.
Solution with reference link could be better.
If you are using Eclipse you can run Lint Error Checking to know which files are used and which ones aren't.
Go to Window->Preferences->Android->Lint Error Checking
If you do any change in the list of enabled checks and click Apply you will be asked if you want to run lint. Click Yes and all the files that you aren't using will be marked with a warning.
Android Lint will do this for you. Check out Lint Tool - I guess, it otherwise depends on which IDE you're using. I know that IntelliJ will mark unused items in the main R.java file itself. But afaik, Eclipse doesn't do this.
Best bet is to use Lint. You can run it from command line also, so doesn't matter what IDE you're using.
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"?