36

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.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Karthik
  • 676
  • 1
  • 8
  • 20

4 Answers4

117

Right click on project - >BuildPath - >Configure BuildPath - >Libraries tab - >

Double click on JRE SYSTEM LIBRARY - >Then select alternate JRE

thegrinner
  • 11,546
  • 5
  • 41
  • 64
PSR
  • 39,804
  • 41
  • 111
  • 151
47

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 .

James King
  • 6,229
  • 3
  • 25
  • 40
Alter Hu
  • 739
  • 1
  • 7
  • 15
1

This is an issue relating JRE.In my case (eclipse Luna with Maven plugin, JDK 7) I solved this by making following change in pom.xml and then Maven Update Project.

from:

 <configuration>
        <source>1.8</source>
        <target>1.8</target>
</configuration>

to:

 <configuration>
        <source>1.7</source>
        <target>1.7</target>
</configuration>

Screenshot showing problem in JRE: enter image description here

Dexter
  • 4,036
  • 3
  • 47
  • 55
0

If by chance you have deleted JRE SYSTEM LIBRARY, then go to your JRE installation and add jars from there.

Eg:- C:\Program Files (x86)\Java\jre7\lib ---add jars from here

C:\Program Files (x86)\Java\jre7\lib\ext ---add jars from here

Divya
  • 11
  • 3