I cant run files because "Java file outside of source root Intellij"

166 Views Asked by At

I have been trying to figure out why I cannot run my java files, I cloned this repository from git hub as part of a university project, I can edit code, commit and do basically everything other than actually run the files. Could anyone point me in the right direction?

This is how the project looks right now. (I am a newbie to java and IntelliJ)

enter image description here

I have tried messing on with the project configuration and the project structure but i've had no luck.

2

There are 2 best solutions below

0
Nadia Tarashkevich On

In the editor, click the gutter icon to run the application and select Run 'Main.main()'.

Here is the corresponding documentation:

https://www.jetbrains.com/help/idea/run-java-applications.html#run_application

0
Jacky Liu On

You should tell the IDEA where is the source folder, you may choose the menu File | Project Structure..., in the dialog, choose Modules , then choose the project folder, and click the mark as Sources to make the root folder as the project root folder. Although this is not recommended as usually put all sources under a folder named src, but it should work.

enter image description here

For more info, please ref:

https://www.jetbrains.com/help/idea/2023.3/modules.html

https://www.jetbrains.com/help/idea/2023.3/sdk.html#set-up-jdk