1

I use to work on Eclipse and now I want to migrate to IntelliJ. On Eclipse I had a set of projects on the same workspace. I am trying to map that in modules on the same project, according to instructions from other questions.

Nevertheless, after importing them IntelliJ states the following error:

Package name 'a.b.c.d' does not correspond to the file path 'source.src.a.b.c.d'

This error just happens in a specific module.

After some reading about the error, I tried to create a new project for test purpose and import just the broken module and it worked as expected.

What am I missing?

  • You should probably try using File -> New -> "Create new project from Existing source" and Intellij would properly format the folder structure – Shweta Jul 28 '16 at 17:42
  • 1
    This issue could be caused by this: https://stackoverflow.com/questions/43899453/intellij-source-root-is-not-handled-correctly. Please check this link too. – floating cat Jun 23 '20 at 12:59

1 Answers1

0

The source directories for the project were apparently not imported correctly. Since for Java, directory structure = package path, if IntelliJ thinks that your sources reside in / (instead of /source/src), it will think that the package name should be source.src.a.b.c.d.

Basically, go to File -> Project Structure, find the proper Module, then on the right hand side remove the root directory as a source folder and add all the relevant subdirectories as source folders (i.e. remove "." and add "src/source").

observer
  • 2,925
  • 1
  • 19
  • 38
Piotr Wilkin
  • 3,446
  • 10
  • 18
  • I tried this before, for some reason it messes up all the package. I am almost giving up and downloading Eclipse. If I open the module again it will still states that the "." is there and the "src/source" – Rodrigo Borcat Jul 28 '16 at 18:14
  • You seem to have overlapping source roots. If you have both "." and "src/source", you should remove "." and just leave the "src/source". Otherwise, it will include the same packages twice, but with different relative paths, which is asking for trouble. – Piotr Wilkin Jul 28 '16 at 18:20
  • Also, since I am a migrant from Eclipse myself, I can tell you how I did it: you should follow stillLearning's advice from the comment above and import each project as an IntelliJ project (instead of as a module), then create a new meta-project and add all the already-imported IntelliJ projects as modules (via "Module from existing sources..."). – Piotr Wilkin Jul 28 '16 at 18:22
  • I had to download eclipse again due to work urgencies. I will test again this new approach that you said. Thanks in advice! – Rodrigo Borcat Aug 01 '16 at 13:27