Wednesday, January 21, 2015

Eclipse : What does cross sign means in project ...................

Question:
I have a project opened in eclipse, its a java web application. In eclipse I can see that there is a red cross sign with my project name, On expanding my project I can see many files have the same red cross sign.
What does this cross sign means in eclipse? Is it showing some compilation error? if error how can I see the error? Also what does that triangle icon means?
enter image description here
Please check the screenshot above and see the cross and triangle signs...

Answers:

The cross on red ground means an error in this file, while a question mark on yellow ground indicates a warning. You can see them in the Problems tab in eclipse:
Eclipse problems tab
You can customize what is treated as an error and as a warning under Window -> Preferences and then search for errors/warnings (Also take a look at the docs: Java Compiler Errors/Warnings Preferences
In addition to the markings on the resources, you can see errors and warnings in an open file next to the scroll bar:























enter image description here
Cross sign shows the error in that Source,Triangle indicates that your source has some warinings
Just open those files could find the Red x under line and marks in the source editor , if warnings will be displayed as Triangle with ! in the side bar of the source editor.

If your source code is large then you can use shortcut ctrl + . to see the errors in the source file. The following shortcuts will move to the warnings and errors from top to bottom in your eclipse

Few shortcuts to see the errors in eclipse:
Next error: `Ctrl + .`
Previous error: `Ctrl + ,`
Quick fixes: `Ctrl + 1`
 
 
The cross sign indicates that the file web.xml has some error. Also, possibly some files within the 'jsp' and 'lib' directories also have error.
The yellow triangles are warnings. To see the details of all, Go to Window -> Show view -> Problems


I don't see anyone mentioning one thing that may be confusing to a beginner: the red X appears on the file with the error as well as on all its parents. These other marks are a great convenience when your tree is collapsed—they lead you to the file in error, but can also cause confusion when viewing an expanded tree.

Every error marked with the red X annotation also appears in the Problems view, if the view's filter is properly configured. You configure the filter through the view's local menu (accessed through the little downward-facing triangle in the top-right corner of the view's title bar).



 

Eclipse : The import .... cannot be resolved



Question :

I use Eclipse and turns out I have a bunch of import * not resolved errors.
 
 
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
All of the above have the same error. I checked my java version it is 1.7.0 open jdk. I updated Java Home and the JRE library to use. Its still not working. Note: I imported the code repository from bibucket via the mercurial plugin itself.

Answers: 

Did you check the installed JREs in your eclipse. Path is windows preferences - > java -> installed JREs ....as below in detail.

Right click on project - >BuildPath - >Configure BuildPath - >Libraries tab - >
Double click on JRE SYSTEM LIBRARY - >Then select alternate JRE

 -----------------------------------------------------------------------------------------------------
If the project is Maven, you can try this way :
  1. right click the "Maven Dependencies"-->"Build Path"-->"Remove from the build path";
  2. right click the project ,navigate to "Maven"--->"Update project....";
Then the import issue should be solved .

------------------------------------------------------------------------------------------------------Try cleaning your project by going to the following menu item:
Project > Clean

If that doesn't work, try removing the jars from the build path and adding them again.

------------------------------------------------------------------------------------------------------
Clean the project. And double-check the jars being really on the build path (with no errors). Also make sure there is nothing in the "Problems" view.

----------------------------------------------------------------------------------------------------------

 I found the problem. It was the hibernate3.jar. I don't know why it was not well extracted from the .zip, maybe corrupt. A good way to check if jars are corrupt or not is navigating through their tree structure in "Project Explorer" in Eclipse: if you can't expand a jar node probably it's corrupt. I've seen that having corrupt packages it's frequent when you drag and drop them to the "Project Explorer". Maybe it's better to move and copy them in the OS environment! Thankyou all.

--------------------------------------------------------------------------------------------------------------

I  had the problem, that the classpath was broken somehow.
So right click on the project in Package explorer > Plug-in tools > Update classpath... did it for me
---------------------------------------------------------------------------------------------------------------

I  had the same problem because I added a jar I created, where I had set the packaging base directory other than the base directory of the classes. As a result the class e.g. java.util.List had to be imported as util.List although the suggested import was the first one.
Check the imported jars under referenced libraries to see that they are imported correctly

-----------------------------------------------------------------------------------------------------------

I  got the same problem. I downloaded the jar and added it to the build path, but I didn't notice that the extension was .jar.zip. I again converted it to .jar and added to the build path.
It solved my problem. It's a very silly mistake but I wrote it here in case it could help someone.
-----------------------------------------------------------------------------------------------------------------