auto import adding full package name to the line


When using auto-import via the Alt-Enter button, it gives me list of possible classes.  When I click on one I expect it to add the class to the list of imports at the top of the page.  Instead if changes the reference to the fully qualified name.  Is there a way to switch this?  

For example:

    Foo foo = new Foo();

I want this to become:


    Foo foo = new Foo();

but instead I get this: foo = new;


Make sure this option is not enabled:


That's not checked.  My settings look similar except I have 5 and 3 respective for the counts.  


Please share a sample project with the exact steps to reproduce.


What's the easiest way to do that?  You want the actual IDEA project?  

Here's the repository:

I'm using the sbt plugin, which may or may not be related.  I get these kind of warnings for classes that are in the same package.  

Before alt-enter: 

after alt-enter:



Package statement doesn't correspond to the class location (package), hence the problem. Please fix it and imports will work.


I having the same problem with 2017.3 EAP.

alt-enter generates:

import org.slf4j.*;

import javax.ejb.*;
import javax.persistence.*;
import java.util.*;

The package name matches the directory structure.



Hello Roger,

Could you please clarify what is wrong with the import? Also it would be great if you could provide sample project example.



Updating my IntelliJ seems to have fixed the problem. I was using:

IntelliJ IDEA 2018.2.8 (Ultimate Edition)
Build #IU-182.5262.2, built on March 28, 2019

I upgraded to:

IntelliJ IDEA 2019.1.2 (Ultimate Edition)
Build #IU-191.7141.44, built on May 7, 2019


IntelliJ IDEA 2019.2.2 (Ultimate Edition)
Build #IU-192.6603.28, built on September 6, 2019

IDEA does not put a path to the import section if dependency is higher in the structure. 



    ╠ dependency_class

    ╚ inner_folder

        ╚ file_with_dependecy_class

file_with_dependecy_class will have a variable with type <full_path.src_folder.dependency_class> and highlighted 'Unnecessarry qualified reference'. Action 'replace qualified name with import' do nothing. 

Put import manually does not see src_folder, but as variable type sees correct.


This is an acquired behavior because the project was obtained from the git repository with the correct view, but IDEA itself made changes to the import.

Same behavior for structure :


╚ src

   ╚ main

      ╚ java

         ╚ org

            ╚ project

               ╚ subfolder

                  ╠ dependency_class

                  ╚ inner_folder

                     ╚ file_with_dependecy_class




Please upload the sample project at and specify the file name.


I have the same problem on Ubuntu 19.04 with 

IntelliJ IDEA 2019.2.3 (Ultimate Edition)
Build #IU-192.6817.14, built on September 24, 2019


For me it is when importing generated classes.


Fs, we'd appreciate a sample project to reproduce it, thanks.


I found the error. For some reason, Idea had messed up the folder structure. On disk the folder structure and package structure was identical for the generated classes, but in Idea the package structure skipped two levels of folders. Starting over and doing a new clone of the repo sorted it out.

I have no sample project to send in.


Hi, I have same issue

I already upload the demo project to


you can check, and try to fix the import 

here is correct import:

import com.example.tutorial.AddressBookProtos.AddressBook;
import com.example.tutorial.AddressBookProtos.Person;



but IDEA always generate this

import com.example.tutorial.AddressBookProtos;


btw, I use Alt+enter to import.


Same problem here.


Henrik, could you please also share a sample project to show the problem that you have? There were multiple different problems mentioned in this thread so it's not clear which one you have.


I had the same problem, too. It turned out to be a cache problem. After clearing the cache, it became normal again...


I am facing same issue. When I use Alt+enter or mouse click (on import tool. tip) to import the required class, Intellij imports fully qualified class name in the code. This makes it so ugly and frustrating. 

Version: Intellij IDEA 2021.1.3 (Ultimate Edition)

I have checked in the settings and made sure "Use fully qualified class names" check box is not clicked in the Java language settings. 

I have tried to clear cache and restart the IDE multiple times and made sure the class hierarchy is right. 

Its kinda a pain to get over this problem and not sure why this simple issue cannot be fixed.


Sadeshpande Do you have any plug-ins installed that override IDE formatting, such as Eclipse Code Formatter? Does it help if you disable it? See also if disabling Settings (Preferences on macOS) | Editor | Code Style | Enable EditorConfig support helps.


Serge Baranov No, I don't have Eclipse Code Formatter. Only plugin installed additionally is Bazel plugin. Other than that all are the ones that come bundled with IDE. 

Yes, I tried disabling EditorConfig as well now, it makes no difference.




Please upload a sample project to reproduce the issue and your code style settings (File | Manage IDE Settings | Export Settings) at, provide the ID here.



I faced the same problem but i've found a solution

My projet was misconfigured. My kotlin source directory was declared as a "resource" directory, not a source directory, in projet structure / modules

Setting the folder as a source directory have fixed the issue


Please sign in to leave a comment.