Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

source > add import

 
rahul karwal
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
is there anyway, where when i add a CLASS TYPE eclipse automatically loads the class in the import statement ie. suppose i added (ResultSet set = stmt.executeQuery()), i want Eclipse to add ResultSet class automatically in the import statement. I tried to add missing import statement by going to source > add import but it didnt do anything, do i have to setup anything before i can use this property.

pls help.
Thanks
aziz dhanani.
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,


suppose i added (ResultSet set = stmt.executeQuery()), i want Eclipse to add ResultSet class automatically in the import statement.


When you write ResultSet, instead write java.sql.ResultSet, I mean, when you type . after java, you should see a popup from where you can select another interface or class, here you will select sql and then type . and again you should see another popup to select ResultSet. After this last selection, you should see ResultSet import statement and ResultSet without its qualified name.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember correctly, "add import" only adds an import for the class your text cursor is positioned in. To add imports for all classes in the current editor, use "organize imports" (ctrl-shift-o).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic