Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent Eclipse from removing * when organizing imports

Tags:

eclipse

Generally, I use import [static] foo.* when I actually want to import everything from foo. So I'd like Eclipse's Organize Imports to keep any imports with * as is and not to replace multiple separate imports with *. Is there a way to do it?

like image 861
Alexey Romanov Avatar asked Jan 07 '14 08:01

Alexey Romanov


2 Answers

You can set the number of static imports needed to use * on Preferences > Java > Code Style > Organize Imports.

like image 197
greg-449 Avatar answered Oct 29 '22 15:10

greg-449


better late then never.

(Eclipse EE 2020-06)

Window > Preferences > Java > Code Style > Organize Imports:

at the bottom of the window : Number of imports for .* (...) Number of static imports for .* (...)

both are set to 99, set them to 2.

The second import from the same package will automatically shorten both imports into a single wildcard import (i.e. the one with '*')

like image 40
fundubentalist Avatar answered Oct 29 '22 15:10

fundubentalist