Class not found
已回答
Hey there. In my souce folder I have a package with a controller and outside that package I have another class(let's call it TestClass). If I want to instantiate that second class in the controller, the IDE signals me that there is no TestClass. What's the problem?
请先登录再写评论。
Make sure module dependencies and roots are configured so that TestClass can be visible from the module where you are trying to use it:
https://www.jetbrains.com/help/idea/working-with-module-dependencies.html
https://www.jetbrains.com/help/idea/configuring-content-roots.html
Thx for the answare Serge. I've made a mistake,I've ment i have a package inside the src folder,not module. Is the answer still the same?
Are you trying to import a class that is in the default package (in the source root folder and not under any package)?
Here you can see exactly what I mean
Java doesn't support importing classes from the default package: https://stackoverflow.com/a/283828/104891.
Move Duck class to some package to be able to import it: https://www.jetbrains.com/help/idea/move-refactorings.html.
Oh,ok,I never realised that. Thanks!