Class not found

Answered

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?

0
6 comments

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

0
Avatar
Permanently deleted user

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?

0

Are you trying to import a class that is in the default package (in the source root folder and not under any package)?

0
Avatar
Permanently deleted user

Here you can see exactly what I mean

0

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.

1
Avatar
Permanently deleted user

Oh,ok,I never realised that. Thanks!

0

Please sign in to leave a comment.