Skip to main content



      Home
Home » Newcomers » Newcomers » Eclipse question re auto insert of import statement
Eclipse question re auto insert of import statement [message #259418] Fri, 27 June 2008 11:57 Go to next message
Eclipse UserFriend
I recall reading somewhere that Eclipse has a feature where you can use
a class in your code and if it is not defined yet, you can hit something
(ctrl-1 ?) and have it automatically know what package to import.

This feature is not working for my packages nor the BlackBerry
packages. Any ideas how to make this work?

Thanks,
Paul
Re: Eclipse question re auto insert of import statement [message #259422 is a reply to message #259418] Fri, 27 June 2008 12:13 Go to previous messageGo to next message
Eclipse UserFriend
I got this one solved -

If you put the cursor on an undefined class and hit ctrl-shift-m
(Windows) then Eclipse should pull in the required import, as long as it
can find it.

My thanks to richard.puckett


Paul Levin wrote:
> I recall reading somewhere that Eclipse has a feature where you can use
> a class in your code and if it is not defined yet, you can hit something
> (ctrl-1 ?) and have it automatically know what package to import.
>
> This feature is not working for my packages nor the BlackBerry
> packages. Any ideas how to make this work?
>
> Thanks,
> Paul
Re: Eclipse question re auto insert of import statement [message #259431 is a reply to message #259422] Fri, 27 June 2008 13:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: eclipse-news.rizzoweb.com

Paul Levin wrote:
> I got this one solved -
>
> If you put the cursor on an undefined class and hit ctrl-shift-m
> (Windows) then Eclipse should pull in the required import, as long as it
> can find it.

Note that Ctrl+Shift+o (Organize Imports) will also insert missing
import statements (it will prompt you if there is ambiguity about which
class to import based on the project's build path).
Also, Ctrl+Space will offer suggestions for fully-qualified class names
and automatically add import statements when you select the exact one
you want. Ctrl+Space is a very powerful tool in general - it does a lot
more than that.

Hope this helps,
Eric


> Paul Levin wrote:
>> I recall reading somewhere that Eclipse has a feature where you can
>> use a class in your code and if it is not defined yet, you can hit
>> something (ctrl-1 ?) and have it automatically know what package to
>> import.
>>
>> This feature is not working for my packages nor the BlackBerry
>> packages. Any ideas how to make this work?
>>
>> Thanks,
>> Paul
Re: Eclipse question re auto insert of import statement [message #259435 is a reply to message #259431] Fri, 27 June 2008 14:04 Go to previous messageGo to next message
Eclipse UserFriend
Thanks Eric. I had tried Ctrl+Space and it was not offering any
suggestions for imports. But Ctrl+shift+m worked perfectly.

I'll certainly play with the other suggestions you gave.

Thanks,
Paul


Eric Rizzo wrote:
> Paul Levin wrote:
>> I got this one solved -
>>
>> If you put the cursor on an undefined class and hit ctrl-shift-m
>> (Windows) then Eclipse should pull in the required import, as long as
>> it can find it.
>
> Note that Ctrl+Shift+o (Organize Imports) will also insert missing
> import statements (it will prompt you if there is ambiguity about which
> class to import based on the project's build path).
> Also, Ctrl+Space will offer suggestions for fully-qualified class names
> and automatically add import statements when you select the exact one
> you want. Ctrl+Space is a very powerful tool in general - it does a lot
> more than that.
>
> Hope this helps,
> Eric
>
>
>> Paul Levin wrote:
>>> I recall reading somewhere that Eclipse has a feature where you can
>>> use a class in your code and if it is not defined yet, you can hit
>>> something (ctrl-1 ?) and have it automatically know what package to
>>> import.
>>>
>>> This feature is not working for my packages nor the BlackBerry
>>> packages. Any ideas how to make this work?
>>>
>>> Thanks,
>>> Paul
Re: Eclipse question re auto insert of import statement [message #259723 is a reply to message #259435] Tue, 01 July 2008 07:04 Go to previous message
Eclipse UserFriend
Paul Levin wrote:
> Thanks Eric. I had tried Ctrl+Space and it was not offering any
> suggestions for imports.
Right. It should only suggest the types. If you then select the type it
will add the import automatically.

Dani
> But Ctrl+shift+m worked perfectly.
>
> I'll certainly play with the other suggestions you gave.
>
> Thanks,
> Paul
>
>
> Eric Rizzo wrote:
>> Paul Levin wrote:
>>> I got this one solved -
>>>
>>> If you put the cursor on an undefined class and hit ctrl-shift-m
>>> (Windows) then Eclipse should pull in the required import, as long
>>> as it can find it.
>>
>> Note that Ctrl+Shift+o (Organize Imports) will also insert missing
>> import statements (it will prompt you if there is ambiguity about
>> which class to import based on the project's build path).
>> Also, Ctrl+Space will offer suggestions for fully-qualified class
>> names and automatically add import statements when you select the
>> exact one you want. Ctrl+Space is a very powerful tool in general -
>> it does a lot more than that.
>>
>> Hope this helps,
>> Eric
>>
>>
>>> Paul Levin wrote:
>>>> I recall reading somewhere that Eclipse has a feature where you can
>>>> use a class in your code and if it is not defined yet, you can hit
>>>> something (ctrl-1 ?) and have it automatically know what package to
>>>> import.
>>>>
>>>> This feature is not working for my packages nor the BlackBerry
>>>> packages. Any ideas how to make this work?
>>>>
>>>> Thanks,
>>>> Paul
Previous Topic:Breadcrumbs only used for Java files?
Next Topic:File Explorer does not work on a Network
Goto Forum:
  


Current Time: Sat Jul 26 01:49:32 EDT 2025

Powered by FUDForum. Page generated in 0.10306 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top