Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package name does not correspond to the file path - IntelliJ

I'm trying to import a project from VCS (well, I'm doing it for the first time actually) and this is my (imported) project's structure:

The file structure

BTW. this screen is made after many tries of changing these directories' properties (in their context menus).

In these source files' I have a following error:

The error in the editor

One time it had nothing against badugi.client but it reported this error only in badugi.server. I have completely no idea how it works...

Also classes in the same directories do not see each other.

Error

This is a code from ClientWorker class which is located (as you can see in the first image) in the same directory as Server so it should know what Server is.

I'm pretty sure this code worked well in my friend's IDE. How do I configure IntelliJ to make it work?

like image 879
Android developer Avatar asked Oct 18 '14 14:10

Android developer


People also ask

How do I specify a file path in Intellij?

If you just want to copy the file path you can use Ctrl + Shift + C . You can also search for action with (Ctrl + Shift + A) (for mac Command + Shift + A) and then it will show you the Keyboard shortcut for particular action. If you want to change the Keymap you can open setting page and search for Keymap.

Where is package name in Intellij?

Press Ctrl+Alt+S to open the IDE settings and select Build, Execution, Deployment | Package Search.

How do I change the default package name in Intellij?

Right-click the package you want to rename and from the context menu, select Refactor | Rename ( Shift+F6 ).

Can I create a package inside a package in Intellij?

You can create a class together with a package. To do so, press Alt+Insert in the Project tool window, select Java Class, and specify the fully qualified name of the class, for example: com. example. helloworld.


1 Answers

I had this same issue, and fixed it by modifying my project's .iml file:

From:

<content url="file://$MODULE_DIR$">   <sourceFolder url="file://$MODULE_DIR$/src/wrong/entry/here" isTestSource="false" />   <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />   <excludeFolder url="file://$MODULE_DIR$/target" /> </content> 

To:

<content url="file://$MODULE_DIR$">   <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />   <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />   <excludeFolder url="file://$MODULE_DIR$/target" /> </content> 

Somehow a package folder became specified as the root source directory when this project was imported.

like image 133
Trann Avatar answered Oct 13 '22 05:10

Trann