Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error:missing package statement 'src' but still can run the code in IntelliJ

I'm new to Java, I created a repo in Gitlab and imported to IntelliJ, it's a new repo so nothing in the folder now. I created a folder 'src' manually on my machine and created a java file.

public class Test{
  public static void main(String[] args)
  {
    System.out.println("This is a test!");
  }

}

The code works fine, but the first line under 'Test' there's a curvy red line, normally if I create a new project in IntelliJ, I won't have this kind of problem, is it because I can't create 'src' folder manually? How can I fix this? enter image description here

like image 983
wawawa Avatar asked Oct 14 '25 18:10

wawawa


1 Answers

try to mark the folder src you created as source in: File->project structure->Modules

like image 82
ced ales Avatar answered Oct 17 '25 07:10

ced ales



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!